Sample code for 30+ languages & platforms
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

Unicode C++
#include <CkHttpW.h>
#include <CkCertW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkHttpW http;
    const wchar_t *domain = L"chilkatsoft.com";
    int port = 443;

    //  ------------------------------------------------------------------------
    //  The GetServerSslCert method is deprecated:

    CkCertW *cert1 = http.GetServerSslCert(domain,port);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%s\n",cert1->subjectDN());
    delete 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.

    CkCertW cert2;
    success = http.GetServerCert(domain,port,cert2);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%s\n",cert2.subjectDN());
    }