Unicode C
Unicode C
Transition from Http.GetServerSslCert to Http.GetServerCert
See more HTTP Examples
Provides instructions for replacing deprecated GetServerSslCert method calls with GetServerCert.Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkCertW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
const wchar_t *domain;
int port;
HCkCertW cert1;
HCkCertW cert2;
success = FALSE;
http = CkHttpW_Create();
domain = L"chilkatsoft.com";
port = 443;
// ------------------------------------------------------------------------
// The GetServerSslCert method is deprecated:
cert1 = CkHttpW_GetServerSslCert(http,domain,port);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
return;
}
wprintf(L"%s\n",CkCertW_subjectDN(cert1));
CkCertW_Dispose(cert1);
// ------------------------------------------------------------------------
// Do the equivalent using GetServerCert.
// Your application creates a new, empty certificate object which is passed
// in the last argument and filled with the server certificate upon success.
cert2 = CkCertW_Create();
success = CkHttpW_GetServerCert(http,domain,port,cert2);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkCertW_Dispose(cert2);
return;
}
wprintf(L"%s\n",CkCertW_subjectDN(cert2));
CkHttpW_Dispose(http);
CkCertW_Dispose(cert2);
}