Sample code for 30+ languages & platforms
C++ Requires Chilkat v11.0.0+

Transition from Cert.ExportPrivateKey to Cert.GetPrivateKey

Provides instructions for replacing deprecated ExportPrivateKey method calls with GetPrivateKey.

Chilkat C++ Downloads

C++
#include <CkCert.h>
#include <CkPrivateKey.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCert cert;

    //  ------------------------------------------------------------------------
    //  The ExportPrivateKey method is deprecated:

    CkPrivateKey *privatekeyObj = cert.ExportPrivateKey();
    if (cert.get_LastMethodSuccess() == false) {
        std::cout << cert.lastErrorText() << "\r\n";
        return;
    }

    //  ...
    //  ...

    delete privatekeyObj;

    //  ------------------------------------------------------------------------
    //  Do the equivalent using GetPrivateKey.
    //  Your application creates a new, empty PrivateKey object which is passed 
    //  in the last argument and filled upon success.

    CkPrivateKey privatekeyOut;
    success = cert.GetPrivateKey(privatekeyOut);
    if (success == false) {
        std::cout << cert.lastErrorText() << "\r\n";
        return;
    }
    }