Hi, pure gentlemen ^^
Does anyone know any external HTTPS library with ability to access received server certificate info, and of course allowing to reject connection if don't like it? Need this for one stuff and will translate it to PB if not already.
HTTPS & Purebasic
HTTPS & Purebasic
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: HTTPS & Purebasic
curl
If you enable verbose output you can get the informations of the certificate
Commandline example:
https://forum.ivorde.com/using-curl-to- ... 16141.html
If you enable verbose output you can get the informations of the certificate
Commandline example:
https://forum.ivorde.com/using-curl-to- ... 16141.html
Re: HTTPS & Purebasic
Thanks for info, I was found your bindings already while googled, but was not sure that curl allows this.infratec wrote:curl
Will try it, hope one built-in to PB has all the stuff for cert info ^^
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: HTTPS & Purebasic
Unfortunally it hasn't :/
Well should build own or seek for someone else binaries.
Well should build own or seek for someone else binaries.
Code: Select all
#CURLOPT_CERTINFO = 172
; working with static libcurl
InitNetwork()
IncludeFile "libcurl.pbi"
EnableExplicit
Procedure wrfu(*ptr, size, nmemb, *stream)
ProcedureReturn size * nmemb
EndProcedure
Procedure Main ()
curl_global_init(#CURL_GLOBAL_DEFAULT);
Protected CURL = curl_easy_init()
Protected res
;Debug PeekS(curl_version(), -1, #PB_Ascii)
If(curl)
curl_easy_setopt(curl, #CURLOPT_URL, "https://www.example.com/")
curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @wrfu())
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
curl_easy_setopt(curl, #CURLOPT_VERBOSE, 0)
Debug curl_easy_setopt(curl, #CURLOPT_CERTINFO, 1) ; = CURLE_NOT_BUILT_IN
res = curl_easy_perform(curl)
; If Not res
; union {
; struct curl_slist *to_info;
; struct curl_certinfo *to_certinfo;
; } ptr;
;
; ptr.to_info = NULL;
;
; res = curl_easy_getinfo(curl, #CURLINFO_CERTINFO, &ptr.to_info);
;
; If Not res And ptr.to_info)
; int i;
;
; printf("%d certs!\n", ptr.to_certinfo->num_of_certs);
;
; For(i = 0; i < ptr.to_certinfo->num_of_certs; i++) {
; struct curl_slist *slist;
;
; For(slist = ptr.to_certinfo->certinfo[i]; slist; slist = slist->next)
; printf("%s\n", slist->Data);
;
; }
; EndIf
;
; EndIf
curl_easy_cleanup(curl);
EndIf
curl_global_cleanup()
ProcedureReturn 0
EndProcedure
Main()
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: HTTPS & Purebasic
Would also love to see this workLunasole wrote:Unfortunally it hasn't :/
Well should build own or seek for someone else binaries.
Code: Select all
#CURLOPT_CERTINFO = 172 ; working with static libcurl InitNetwork() IncludeFile "libcurl.pbi" EnableExplicit Procedure wrfu(*ptr, size, nmemb, *stream) ProcedureReturn size * nmemb EndProcedure Procedure Main () curl_global_init(#CURL_GLOBAL_DEFAULT); Protected CURL = curl_easy_init() Protected res ;Debug PeekS(curl_version(), -1, #PB_Ascii) If(curl) curl_easy_setopt(curl, #CURLOPT_URL, "https://www.example.com/") curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @wrfu()) curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0) curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0) curl_easy_setopt(curl, #CURLOPT_VERBOSE, 0) Debug curl_easy_setopt(curl, #CURLOPT_CERTINFO, 1) ; = CURLE_NOT_BUILT_IN res = curl_easy_perform(curl) ; If Not res ; union { ; struct curl_slist *to_info; ; struct curl_certinfo *to_certinfo; ; } ptr; ; ; ptr.to_info = NULL; ; ; res = curl_easy_getinfo(curl, #CURLINFO_CERTINFO, &ptr.to_info); ; ; If Not res And ptr.to_info) ; int i; ; ; printf("%d certs!\n", ptr.to_certinfo->num_of_certs); ; ; For(i = 0; i < ptr.to_certinfo->num_of_certs; i++) { ; struct curl_slist *slist; ; ; For(slist = ptr.to_certinfo->certinfo[i]; slist; slist = slist->next) ; printf("%s\n", slist->Data); ; ; } ; EndIf ; ; EndIf curl_easy_cleanup(curl); EndIf curl_global_cleanup() ProcedureReturn 0 EndProcedure Main()
Re: HTTPS & Purebasic
Please pardon my English, my native tongue is German.