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

Transition from Cert.ExportPrivateKey to Cert.GetPrivateKey

Provides instructions for replacing deprecated ExportPrivateKey method calls with GetPrivateKey.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
cert: HCkCert;
privatekeyObj: HCkPrivateKey;
privatekeyOut: HCkPrivateKey;

begin
success := False;

cert := CkCert_Create();

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

privatekeyObj := CkCert_ExportPrivateKey(cert);
if (CkCert_getLastMethodSuccess(cert) = False) then
  begin
    Memo1.Lines.Add(CkCert__lastErrorText(cert));
    Exit;
  end;

//  ...
//  ...

CkPrivateKey_Dispose(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.

privatekeyOut := CkPrivateKey_Create();
success := CkCert_GetPrivateKey(cert,privatekeyOut);
if (success = False) then
  begin
    Memo1.Lines.Add(CkCert__lastErrorText(cert));
    Exit;
  end;

CkCert_Dispose(cert);
CkPrivateKey_Dispose(privatekeyOut);