unit Chilkat.Cert;

{
  Pascal wrapper for Chilkat Cert.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TCert wraps CkCert via the C bridge layer. }
  TCert = class(TChilkatBase)
  private
    FOnAbortCheck: TChilkatAbortCheckEvent;
    FOnPercentDone: TChilkatPercentDoneEvent;
    FOnProgressInfo: TChilkatProgressInfoEvent;
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
    function  GetAuthorityKeyId: string;
    function  GetAvoidWindowsPkAccess: Boolean;
    procedure SetAvoidWindowsPkAccess(AValue: Boolean);
    function  GetCertVersion: Integer;
    function  GetExpired: Boolean;
    function  GetForClientAuthentication: Boolean;
    function  GetForCodeSigning: Boolean;
    function  GetForSecureEmail: Boolean;
    function  GetForServerAuthentication: Boolean;
    function  GetForTimeStamping: Boolean;
    function  GetIntendedKeyUsage: LongWord;
    function  GetIsRoot: Boolean;
    function  GetIssuerC: string;
    function  GetIssuerCN: string;
    function  GetIssuerDN: string;
    function  GetIssuerE: string;
    function  GetIssuerL: string;
    function  GetIssuerO: string;
    function  GetIssuerOU: string;
    function  GetIssuerS: string;
    function  GetOcspUrl: string;
    function  GetPrivateKeyExportable: Boolean;
    function  GetRevoked: Boolean;
    function  GetRfc822Name: string;
    function  GetSelfSigned: Boolean;
    function  GetSerialNumber: string;
    function  GetSha1Thumbprint: string;
    function  GetSignatureVerified: Boolean;
    function  GetSubjectC: string;
    function  GetSubjectCN: string;
    function  GetSubjectDN: string;
    function  GetSubjectE: string;
    function  GetSubjectKeyId: string;
    function  GetSubjectL: string;
    function  GetSubjectO: string;
    function  GetSubjectOU: string;
    function  GetSubjectS: string;
    function  GetTrustedRoot: Boolean;
    function  GetValidFromStr: string;
    function  GetValidToStr: string;
    function  GetSerialDecimal: string;
    function  GetSmartCardPin: string;
    procedure SetSmartCardPin(AValue: string);
    function  GetSmartCardNoDialog: Boolean;
    procedure SetSmartCardNoDialog(AValue: Boolean);
    function  GetExtendedKeyUsage: string;
    function  GetSubjectAlternativeName: string;
    function  GetUncommonOptions: string;
    procedure SetUncommonOptions(AValue: string);
    function  GetSmartCardFailReason: Integer;
    procedure SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
    procedure SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
    procedure SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;
    property AuthorityKeyId: string read GetAuthorityKeyId;
    property AvoidWindowsPkAccess: Boolean read GetAvoidWindowsPkAccess write SetAvoidWindowsPkAccess;
    property CertVersion: Integer read GetCertVersion;
    property Expired: Boolean read GetExpired;
    property ForClientAuthentication: Boolean read GetForClientAuthentication;
    property ForCodeSigning: Boolean read GetForCodeSigning;
    property ForSecureEmail: Boolean read GetForSecureEmail;
    property ForServerAuthentication: Boolean read GetForServerAuthentication;
    property ForTimeStamping: Boolean read GetForTimeStamping;
    property IntendedKeyUsage: LongWord read GetIntendedKeyUsage;
    property IsRoot: Boolean read GetIsRoot;
    property IssuerC: string read GetIssuerC;
    property IssuerCN: string read GetIssuerCN;
    property IssuerDN: string read GetIssuerDN;
    property IssuerE: string read GetIssuerE;
    property IssuerL: string read GetIssuerL;
    property IssuerO: string read GetIssuerO;
    property IssuerOU: string read GetIssuerOU;
    property IssuerS: string read GetIssuerS;
    property OcspUrl: string read GetOcspUrl;
    property PrivateKeyExportable: Boolean read GetPrivateKeyExportable;
    property Revoked: Boolean read GetRevoked;
    property Rfc822Name: string read GetRfc822Name;
    property SelfSigned: Boolean read GetSelfSigned;
    property SerialNumber: string read GetSerialNumber;
    property Sha1Thumbprint: string read GetSha1Thumbprint;
    property SignatureVerified: Boolean read GetSignatureVerified;
    property SubjectC: string read GetSubjectC;
    property SubjectCN: string read GetSubjectCN;
    property SubjectDN: string read GetSubjectDN;
    property SubjectE: string read GetSubjectE;
    property SubjectKeyId: string read GetSubjectKeyId;
    property SubjectL: string read GetSubjectL;
    property SubjectO: string read GetSubjectO;
    property SubjectOU: string read GetSubjectOU;
    property SubjectS: string read GetSubjectS;
    property TrustedRoot: Boolean read GetTrustedRoot;
    property ValidFromStr: string read GetValidFromStr;
    property ValidToStr: string read GetValidToStr;
    property SerialDecimal: string read GetSerialDecimal;
    property SmartCardPin: string read GetSmartCardPin write SetSmartCardPin;
    property SmartCardNoDialog: Boolean read GetSmartCardNoDialog write SetSmartCardNoDialog;
    property ExtendedKeyUsage: string read GetExtendedKeyUsage;
    property SubjectAlternativeName: string read GetSubjectAlternativeName;
    property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;
    property SmartCardFailReason: Integer read GetSmartCardFailReason;

    { Event callbacks.  Return True from OnAbortCheck / OnPercentDone
      to abort the running method.  Callbacks are invoked on the
      thread that called the Chilkat method.  The HeartbeatMs
      property controls the AbortCheck frequency. }
    property OnAbortCheck: TChilkatAbortCheckEvent read FOnAbortCheck write SetOnAbortCheck;
    property OnPercentDone: TChilkatPercentDoneEvent read FOnPercentDone write SetOnPercentDone;
    property OnProgressInfo: TChilkatProgressInfoEvent read FOnProgressInfo write SetOnProgressInfo;

    function  CheckRevoked: Integer;
    function  ExportCertDerFile(const path: string): Boolean;
    function  ExportCertPem: string;
    function  ExportCertPemFile(const path: string): Boolean;
    function  ExportCertXml: string;
    function  ExportToPfxFile(const pfxFilename: string; const pfxPassword: string; bIncludeCertChain: Boolean): Boolean;
    function  FindIssuer: TChilkatBase;
    function  GetEncoded: string;
    function  GetExtensionAsXml(const oid: string): string;
    function  GetPrivateKeyPem: string;
    function  GetSpkiFingerprint(const hashAlg: string; const encoding: string): string;
    function  HasPrivateKey: Boolean;
    function  LoadByCommonName(const cn: string): Boolean;
    function  LoadByEmailAddress(const emailAddress: string): Boolean;
    function  LoadByIssuerAndSerialNumber(const issuerCN: string; const serialNumber: string): Boolean;
    function  LoadFromBase64(const encodedCert: string): Boolean;
    function  LoadFromFile(const path: string): Boolean;
    function  LoadPem(const strPem: string): Boolean;
    function  LoadPfxFile(const pfxPath: string; const password: string): Boolean;
    function  PemFileToDerFile(const fromPath: string; const toPath: string): Boolean;
    function  SaveToFile(const path: string): Boolean;
    function  SetFromEncoded(const encodedCert: string): Boolean;
    function  SetPrivateKey(privKey: TChilkatBase): Boolean;
    function  SetPrivateKeyPem(const privKeyPem: string): Boolean;
    function  UseCertVault(vault: TChilkatBase): Boolean;
    function  VerifySignature: Boolean;
    function  ExportToPfxBd(const password: string; includeCertChain: Boolean; pfxData: TChilkatBase): Boolean;
    function  ExportCertDerBd(cerData: TChilkatBase): Boolean;
    function  LoadPfxBd(pfxData: TChilkatBase; const password: string): Boolean;
    function  LoadFromBd(certBytes: TChilkatBase): Boolean;
    function  HashOf(const part: string; const hashAlg: string; const encoding: string): string;
    function  CheckSmartCardPin: Integer;
    function  X509PKIPathv1: string;
    function  LoadFromSmartcard(const certSpec: string): Boolean;
    function  LoadByThumbprint(const thumbprint: string; const encoding: string): Boolean;
    function  LoadBySubjectOid(const oid: string; const value: string): Boolean;
    function  GetSubjectPart(const partNameOrOid: string): string;
    function  GetExtensionAsText(const oid: string): string;
    function  GetPubKeyDer(preferPkcs1: Boolean; bd: TChilkatBase): Boolean;
    function  GetSignature(bd: TChilkatBase): Boolean;
    function  GetExtensionBd(const oid: string; bd: TChilkatBase): Boolean;
    function  LinkPkcs11(session: TChilkatBase): Boolean;
    function  UploadToCloud(jsonIn: TChilkatBase; jsonOut: TChilkatBase): Boolean;
    function  SetCloudSigner(json: TChilkatBase): Boolean;
    function  IsRsa: Boolean;
    function  IsEcdsa: Boolean;
    function  Unload: Boolean;
    function  GetPrivateKey(privKey: TChilkatBase): Boolean;
    function  GetPublicKey(pubKey: TChilkatBase): Boolean;
    function  GetIssuer(issuer: TChilkatBase): Boolean;
    function  BuildCertChain(certChain: TChilkatBase): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkCert_Create  = function(): Pointer; cdecl;
  TCkCert_Dispose = procedure(handle: Pointer); cdecl;
  TCkBridgeAbortCheckCb   = function(userData: Pointer): Integer; cdecl;
  TCkBridgePercentDoneCb  = function(pctDone: Integer; userData: Pointer): Integer; cdecl;
  TCkBridgeProgressInfoCb = procedure(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
  TCkCert_SetAbortCheckCallback   = procedure(handle: Pointer; cb: TCkBridgeAbortCheckCb; userData: Pointer); cdecl;
  TCkCert_SetPercentDoneCallback  = procedure(handle: Pointer; cb: TCkBridgePercentDoneCb; userData: Pointer); cdecl;
  TCkCert_SetProgressInfoCallback = procedure(handle: Pointer; cb: TCkBridgeProgressInfoCb; userData: Pointer); cdecl;
  TCkCert_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkCert_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkCert_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCert_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkCert_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCert_get_AuthorityKeyId = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_AvoidWindowsPkAccess = function(handle: Pointer): LongBool; cdecl;
  TCkCert_put_AvoidWindowsPkAccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCert_get_CertVersion = function(handle: Pointer): Integer; cdecl;
  TCkCert_get_Expired = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_ForClientAuthentication = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_ForCodeSigning = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_ForSecureEmail = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_ForServerAuthentication = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_ForTimeStamping = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_IntendedKeyUsage = function(handle: Pointer): LongWord; cdecl;
  TCkCert_get_IsRoot = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_IssuerC = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerCN = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerDN = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerE = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerL = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerO = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerOU = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_IssuerS = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_OcspUrl = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_PrivateKeyExportable = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_Revoked = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_Rfc822Name = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SelfSigned = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_SerialNumber = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_Sha1Thumbprint = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SignatureVerified = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_SubjectC = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectCN = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectDN = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectE = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectKeyId = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectL = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectO = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectOU = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectS = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_TrustedRoot = function(handle: Pointer): LongBool; cdecl;
  TCkCert_get_ValidFromStr = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_ValidToStr = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SerialDecimal = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SmartCardPin = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_put_SmartCardPin = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkCert_get_SmartCardNoDialog = function(handle: Pointer): LongBool; cdecl;
  TCkCert_put_SmartCardNoDialog = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCert_get_ExtendedKeyUsage = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_SubjectAlternativeName = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_get_UncommonOptions = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_put_UncommonOptions = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkCert_get_SmartCardFailReason = function(handle: Pointer): Integer; cdecl;
  TCkCert_CheckRevoked = function(handle: Pointer): Integer; cdecl;
  TCkCert_ExportCertDerFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkCert_ExportCertPem = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_ExportCertPemFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkCert_ExportCertXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_ExportToPfxFile = function(handle: Pointer; pfxFilename: PAnsiChar; pfxPassword: PAnsiChar; bIncludeCertChain: LongBool): LongBool; cdecl;
  TCkCert_FindIssuer = function(handle: Pointer): Pointer; cdecl;
  TCkCert_GetEncoded = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_GetExtensionAsXml = function(handle: Pointer; oid: PAnsiChar): PAnsiChar; cdecl;
  TCkCert_GetPrivateKeyPem = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_GetSpkiFingerprint = function(handle: Pointer; hashAlg: PAnsiChar; encoding: PAnsiChar): PAnsiChar; cdecl;
  TCkCert_HasPrivateKey = function(handle: Pointer): LongBool; cdecl;
  TCkCert_LoadByCommonName = function(handle: Pointer; cn: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadByEmailAddress = function(handle: Pointer; emailAddress: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadByIssuerAndSerialNumber = function(handle: Pointer; issuerCN: PAnsiChar; serialNumber: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadFromBase64 = function(handle: Pointer; encodedCert: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadFromFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadPem = function(handle: Pointer; strPem: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadPfxFile = function(handle: Pointer; pfxPath: PAnsiChar; password: PAnsiChar): LongBool; cdecl;
  TCkCert_PemFileToDerFile = function(handle: Pointer; fromPath: PAnsiChar; toPath: PAnsiChar): LongBool; cdecl;
  TCkCert_SaveToFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkCert_SetFromEncoded = function(handle: Pointer; encodedCert: PAnsiChar): LongBool; cdecl;
  TCkCert_SetPrivateKey = function(handle: Pointer; privKey: Pointer): LongBool; cdecl;
  TCkCert_SetPrivateKeyPem = function(handle: Pointer; privKeyPem: PAnsiChar): LongBool; cdecl;
  TCkCert_UseCertVault = function(handle: Pointer; vault: Pointer): LongBool; cdecl;
  TCkCert_VerifySignature = function(handle: Pointer): LongBool; cdecl;
  TCkCert_ExportToPfxBd = function(handle: Pointer; password: PAnsiChar; includeCertChain: LongBool; pfxData: Pointer): LongBool; cdecl;
  TCkCert_ExportCertDerBd = function(handle: Pointer; cerData: Pointer): LongBool; cdecl;
  TCkCert_LoadPfxBd = function(handle: Pointer; pfxData: Pointer; password: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadFromBd = function(handle: Pointer; certBytes: Pointer): LongBool; cdecl;
  TCkCert_HashOf = function(handle: Pointer; part: PAnsiChar; hashAlg: PAnsiChar; encoding: PAnsiChar): PAnsiChar; cdecl;
  TCkCert_CheckSmartCardPin = function(handle: Pointer): Integer; cdecl;
  TCkCert_X509PKIPathv1 = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCert_LoadFromSmartcard = function(handle: Pointer; certSpec: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadByThumbprint = function(handle: Pointer; thumbprint: PAnsiChar; encoding: PAnsiChar): LongBool; cdecl;
  TCkCert_LoadBySubjectOid = function(handle: Pointer; oid: PAnsiChar; value: PAnsiChar): LongBool; cdecl;
  TCkCert_GetSubjectPart = function(handle: Pointer; partNameOrOid: PAnsiChar): PAnsiChar; cdecl;
  TCkCert_GetExtensionAsText = function(handle: Pointer; oid: PAnsiChar): PAnsiChar; cdecl;
  TCkCert_GetPubKeyDer = function(handle: Pointer; preferPkcs1: LongBool; bd: Pointer): LongBool; cdecl;
  TCkCert_GetSignature = function(handle: Pointer; bd: Pointer): LongBool; cdecl;
  TCkCert_GetExtensionBd = function(handle: Pointer; oid: PAnsiChar; bd: Pointer): LongBool; cdecl;
  TCkCert_LinkPkcs11 = function(handle: Pointer; session: Pointer): LongBool; cdecl;
  TCkCert_UploadToCloud = function(handle: Pointer; jsonIn: Pointer; jsonOut: Pointer): LongBool; cdecl;
  TCkCert_SetCloudSigner = function(handle: Pointer; json: Pointer): LongBool; cdecl;
  TCkCert_IsRsa = function(handle: Pointer): LongBool; cdecl;
  TCkCert_IsEcdsa = function(handle: Pointer): LongBool; cdecl;
  TCkCert_Unload = function(handle: Pointer): LongBool; cdecl;
  TCkCert_GetPrivateKey = function(handle: Pointer; privKey: Pointer): LongBool; cdecl;
  TCkCert_GetPublicKey = function(handle: Pointer; pubKey: Pointer): LongBool; cdecl;
  TCkCert_GetIssuer = function(handle: Pointer; issuer: Pointer): LongBool; cdecl;
  TCkCert_BuildCertChain = function(handle: Pointer; certChain: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkCert_Create:  TCkCert_Create  = nil;
  CkCert_Dispose: TCkCert_Dispose = nil;
  CkCert_SetAbortCheckCallback:   TCkCert_SetAbortCheckCallback   = nil;
  CkCert_SetPercentDoneCallback:  TCkCert_SetPercentDoneCallback  = nil;
  CkCert_SetProgressInfoCallback: TCkCert_SetProgressInfoCallback = nil;
  CkCert_get_LastErrorHtml: TCkCert_get_LastErrorHtml = nil;
  CkCert_get_LastErrorText: TCkCert_get_LastErrorText = nil;
  CkCert_get_LastErrorXml: TCkCert_get_LastErrorXml = nil;
  CkCert_get_Version: TCkCert_get_Version = nil;
  CkCert_get_DebugLogFilePath: TCkCert_get_DebugLogFilePath = nil;
  CkCert_put_DebugLogFilePath: TCkCert_put_DebugLogFilePath = nil;
  CkCert_get_VerboseLogging: TCkCert_get_VerboseLogging = nil;
  CkCert_put_VerboseLogging: TCkCert_put_VerboseLogging = nil;
  CkCert_get_LastMethodSuccess: TCkCert_get_LastMethodSuccess = nil;
  CkCert_put_LastMethodSuccess: TCkCert_put_LastMethodSuccess = nil;
  CkCert_get_AuthorityKeyId: TCkCert_get_AuthorityKeyId = nil;
  CkCert_get_AvoidWindowsPkAccess: TCkCert_get_AvoidWindowsPkAccess = nil;
  CkCert_put_AvoidWindowsPkAccess: TCkCert_put_AvoidWindowsPkAccess = nil;
  CkCert_get_CertVersion: TCkCert_get_CertVersion = nil;
  CkCert_get_Expired: TCkCert_get_Expired = nil;
  CkCert_get_ForClientAuthentication: TCkCert_get_ForClientAuthentication = nil;
  CkCert_get_ForCodeSigning: TCkCert_get_ForCodeSigning = nil;
  CkCert_get_ForSecureEmail: TCkCert_get_ForSecureEmail = nil;
  CkCert_get_ForServerAuthentication: TCkCert_get_ForServerAuthentication = nil;
  CkCert_get_ForTimeStamping: TCkCert_get_ForTimeStamping = nil;
  CkCert_get_IntendedKeyUsage: TCkCert_get_IntendedKeyUsage = nil;
  CkCert_get_IsRoot: TCkCert_get_IsRoot = nil;
  CkCert_get_IssuerC: TCkCert_get_IssuerC = nil;
  CkCert_get_IssuerCN: TCkCert_get_IssuerCN = nil;
  CkCert_get_IssuerDN: TCkCert_get_IssuerDN = nil;
  CkCert_get_IssuerE: TCkCert_get_IssuerE = nil;
  CkCert_get_IssuerL: TCkCert_get_IssuerL = nil;
  CkCert_get_IssuerO: TCkCert_get_IssuerO = nil;
  CkCert_get_IssuerOU: TCkCert_get_IssuerOU = nil;
  CkCert_get_IssuerS: TCkCert_get_IssuerS = nil;
  CkCert_get_OcspUrl: TCkCert_get_OcspUrl = nil;
  CkCert_get_PrivateKeyExportable: TCkCert_get_PrivateKeyExportable = nil;
  CkCert_get_Revoked: TCkCert_get_Revoked = nil;
  CkCert_get_Rfc822Name: TCkCert_get_Rfc822Name = nil;
  CkCert_get_SelfSigned: TCkCert_get_SelfSigned = nil;
  CkCert_get_SerialNumber: TCkCert_get_SerialNumber = nil;
  CkCert_get_Sha1Thumbprint: TCkCert_get_Sha1Thumbprint = nil;
  CkCert_get_SignatureVerified: TCkCert_get_SignatureVerified = nil;
  CkCert_get_SubjectC: TCkCert_get_SubjectC = nil;
  CkCert_get_SubjectCN: TCkCert_get_SubjectCN = nil;
  CkCert_get_SubjectDN: TCkCert_get_SubjectDN = nil;
  CkCert_get_SubjectE: TCkCert_get_SubjectE = nil;
  CkCert_get_SubjectKeyId: TCkCert_get_SubjectKeyId = nil;
  CkCert_get_SubjectL: TCkCert_get_SubjectL = nil;
  CkCert_get_SubjectO: TCkCert_get_SubjectO = nil;
  CkCert_get_SubjectOU: TCkCert_get_SubjectOU = nil;
  CkCert_get_SubjectS: TCkCert_get_SubjectS = nil;
  CkCert_get_TrustedRoot: TCkCert_get_TrustedRoot = nil;
  CkCert_get_ValidFromStr: TCkCert_get_ValidFromStr = nil;
  CkCert_get_ValidToStr: TCkCert_get_ValidToStr = nil;
  CkCert_get_SerialDecimal: TCkCert_get_SerialDecimal = nil;
  CkCert_get_SmartCardPin: TCkCert_get_SmartCardPin = nil;
  CkCert_put_SmartCardPin: TCkCert_put_SmartCardPin = nil;
  CkCert_get_SmartCardNoDialog: TCkCert_get_SmartCardNoDialog = nil;
  CkCert_put_SmartCardNoDialog: TCkCert_put_SmartCardNoDialog = nil;
  CkCert_get_ExtendedKeyUsage: TCkCert_get_ExtendedKeyUsage = nil;
  CkCert_get_SubjectAlternativeName: TCkCert_get_SubjectAlternativeName = nil;
  CkCert_get_UncommonOptions: TCkCert_get_UncommonOptions = nil;
  CkCert_put_UncommonOptions: TCkCert_put_UncommonOptions = nil;
  CkCert_get_SmartCardFailReason: TCkCert_get_SmartCardFailReason = nil;
  CkCert_CheckRevoked: TCkCert_CheckRevoked = nil;
  CkCert_ExportCertDerFile: TCkCert_ExportCertDerFile = nil;
  CkCert_ExportCertPem: TCkCert_ExportCertPem = nil;
  CkCert_ExportCertPemFile: TCkCert_ExportCertPemFile = nil;
  CkCert_ExportCertXml: TCkCert_ExportCertXml = nil;
  CkCert_ExportToPfxFile: TCkCert_ExportToPfxFile = nil;
  CkCert_FindIssuer: TCkCert_FindIssuer = nil;
  CkCert_GetEncoded: TCkCert_GetEncoded = nil;
  CkCert_GetExtensionAsXml: TCkCert_GetExtensionAsXml = nil;
  CkCert_GetPrivateKeyPem: TCkCert_GetPrivateKeyPem = nil;
  CkCert_GetSpkiFingerprint: TCkCert_GetSpkiFingerprint = nil;
  CkCert_HasPrivateKey: TCkCert_HasPrivateKey = nil;
  CkCert_LoadByCommonName: TCkCert_LoadByCommonName = nil;
  CkCert_LoadByEmailAddress: TCkCert_LoadByEmailAddress = nil;
  CkCert_LoadByIssuerAndSerialNumber: TCkCert_LoadByIssuerAndSerialNumber = nil;
  CkCert_LoadFromBase64: TCkCert_LoadFromBase64 = nil;
  CkCert_LoadFromFile: TCkCert_LoadFromFile = nil;
  CkCert_LoadPem: TCkCert_LoadPem = nil;
  CkCert_LoadPfxFile: TCkCert_LoadPfxFile = nil;
  CkCert_PemFileToDerFile: TCkCert_PemFileToDerFile = nil;
  CkCert_SaveToFile: TCkCert_SaveToFile = nil;
  CkCert_SetFromEncoded: TCkCert_SetFromEncoded = nil;
  CkCert_SetPrivateKey: TCkCert_SetPrivateKey = nil;
  CkCert_SetPrivateKeyPem: TCkCert_SetPrivateKeyPem = nil;
  CkCert_UseCertVault: TCkCert_UseCertVault = nil;
  CkCert_VerifySignature: TCkCert_VerifySignature = nil;
  CkCert_ExportToPfxBd: TCkCert_ExportToPfxBd = nil;
  CkCert_ExportCertDerBd: TCkCert_ExportCertDerBd = nil;
  CkCert_LoadPfxBd: TCkCert_LoadPfxBd = nil;
  CkCert_LoadFromBd: TCkCert_LoadFromBd = nil;
  CkCert_HashOf: TCkCert_HashOf = nil;
  CkCert_CheckSmartCardPin: TCkCert_CheckSmartCardPin = nil;
  CkCert_X509PKIPathv1: TCkCert_X509PKIPathv1 = nil;
  CkCert_LoadFromSmartcard: TCkCert_LoadFromSmartcard = nil;
  CkCert_LoadByThumbprint: TCkCert_LoadByThumbprint = nil;
  CkCert_LoadBySubjectOid: TCkCert_LoadBySubjectOid = nil;
  CkCert_GetSubjectPart: TCkCert_GetSubjectPart = nil;
  CkCert_GetExtensionAsText: TCkCert_GetExtensionAsText = nil;
  CkCert_GetPubKeyDer: TCkCert_GetPubKeyDer = nil;
  CkCert_GetSignature: TCkCert_GetSignature = nil;
  CkCert_GetExtensionBd: TCkCert_GetExtensionBd = nil;
  CkCert_LinkPkcs11: TCkCert_LinkPkcs11 = nil;
  CkCert_UploadToCloud: TCkCert_UploadToCloud = nil;
  CkCert_SetCloudSigner: TCkCert_SetCloudSigner = nil;
  CkCert_IsRsa: TCkCert_IsRsa = nil;
  CkCert_IsEcdsa: TCkCert_IsEcdsa = nil;
  CkCert_Unload: TCkCert_Unload = nil;
  CkCert_GetPrivateKey: TCkCert_GetPrivateKey = nil;
  CkCert_GetPublicKey: TCkCert_GetPublicKey = nil;
  CkCert_GetIssuer: TCkCert_GetIssuer = nil;
  CkCert_BuildCertChain: TCkCert_BuildCertChain = nil;

constructor TCert.Create;
begin
  inherited Create;
  FHandle := CkCert_Create();
end;

destructor TCert.Destroy;
begin
  if FHandle <> nil then
    CkCert_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

{ ---- Event callback thunks ---- }
{ Standalone cdecl functions registered with the C bridge.  The bridge
  passes back the userData pointer, which carries the Pascal object
  instance.  A non-zero return value aborts the running method. }

function TCert_AbortCheckThunk(userData: Pointer): Integer; cdecl;
var
  obj: TCert;
begin
  Result := 0;
  obj := TCert(userData);
  if Assigned(obj) and Assigned(obj.FOnAbortCheck) then
    if obj.FOnAbortCheck(obj) then Result := 1;
end;

function TCert_PercentDoneThunk(pctDone: Integer; userData: Pointer): Integer; cdecl;
var
  obj: TCert;
begin
  Result := 0;
  obj := TCert(userData);
  if Assigned(obj) and Assigned(obj.FOnPercentDone) then
    if obj.FOnPercentDone(obj, pctDone) then Result := 1;
end;

procedure TCert_ProgressInfoThunk(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
var
  obj: TCert;
begin
  obj := TCert(userData);
  if Assigned(obj) and Assigned(obj.FOnProgressInfo) then
    obj.FOnProgressInfo(obj, CkToStr(name), CkToStr(value));
end;

procedure TCert.SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
begin
  FOnAbortCheck := AValue;
  if Assigned(AValue) then
    CkCert_SetAbortCheckCallback(FHandle, @TCert_AbortCheckThunk, Self)
  else
    CkCert_SetAbortCheckCallback(FHandle, nil, nil);
end;

procedure TCert.SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
begin
  FOnPercentDone := AValue;
  if Assigned(AValue) then
    CkCert_SetPercentDoneCallback(FHandle, @TCert_PercentDoneThunk, Self)
  else
    CkCert_SetPercentDoneCallback(FHandle, nil, nil);
end;

procedure TCert.SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
begin
  FOnProgressInfo := AValue;
  if Assigned(AValue) then
    CkCert_SetProgressInfoCallback(FHandle, @TCert_ProgressInfoThunk, Self)
  else
    CkCert_SetProgressInfoCallback(FHandle, nil, nil);
end;

function TCert.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkCert_get_LastErrorHtml(FHandle));
end;

function TCert.GetLastErrorText: string;
begin
  Result := CkToStr(CkCert_get_LastErrorText(FHandle));
end;

function TCert.GetLastErrorXml: string;
begin
  Result := CkToStr(CkCert_get_LastErrorXml(FHandle));
end;

function TCert.GetVersion: string;
begin
  Result := CkToStr(CkCert_get_Version(FHandle));
end;

function TCert.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkCert_get_DebugLogFilePath(FHandle));
end;

procedure TCert.SetDebugLogFilePath(AValue: string);
begin
  CkCert_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TCert.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkCert_get_VerboseLogging(FHandle));
end;

procedure TCert.SetVerboseLogging(AValue: Boolean);
begin
  CkCert_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TCert.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkCert_get_LastMethodSuccess(FHandle));
end;

procedure TCert.SetLastMethodSuccess(AValue: Boolean);
begin
  CkCert_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TCert.GetAuthorityKeyId: string;
begin
  Result := CkToStr(CkCert_get_AuthorityKeyId(FHandle));
end;

function TCert.GetAvoidWindowsPkAccess: Boolean;
begin
  Result := Boolean(CkCert_get_AvoidWindowsPkAccess(FHandle));
end;

procedure TCert.SetAvoidWindowsPkAccess(AValue: Boolean);
begin
  CkCert_put_AvoidWindowsPkAccess(FHandle, LongBool(AValue));
end;

function TCert.GetCertVersion: Integer;
begin
  Result := CkCert_get_CertVersion(FHandle);
end;

function TCert.GetExpired: Boolean;
begin
  Result := Boolean(CkCert_get_Expired(FHandle));
end;

function TCert.GetForClientAuthentication: Boolean;
begin
  Result := Boolean(CkCert_get_ForClientAuthentication(FHandle));
end;

function TCert.GetForCodeSigning: Boolean;
begin
  Result := Boolean(CkCert_get_ForCodeSigning(FHandle));
end;

function TCert.GetForSecureEmail: Boolean;
begin
  Result := Boolean(CkCert_get_ForSecureEmail(FHandle));
end;

function TCert.GetForServerAuthentication: Boolean;
begin
  Result := Boolean(CkCert_get_ForServerAuthentication(FHandle));
end;

function TCert.GetForTimeStamping: Boolean;
begin
  Result := Boolean(CkCert_get_ForTimeStamping(FHandle));
end;

function TCert.GetIntendedKeyUsage: LongWord;
begin
  Result := CkCert_get_IntendedKeyUsage(FHandle);
end;

function TCert.GetIsRoot: Boolean;
begin
  Result := Boolean(CkCert_get_IsRoot(FHandle));
end;

function TCert.GetIssuerC: string;
begin
  Result := CkToStr(CkCert_get_IssuerC(FHandle));
end;

function TCert.GetIssuerCN: string;
begin
  Result := CkToStr(CkCert_get_IssuerCN(FHandle));
end;

function TCert.GetIssuerDN: string;
begin
  Result := CkToStr(CkCert_get_IssuerDN(FHandle));
end;

function TCert.GetIssuerE: string;
begin
  Result := CkToStr(CkCert_get_IssuerE(FHandle));
end;

function TCert.GetIssuerL: string;
begin
  Result := CkToStr(CkCert_get_IssuerL(FHandle));
end;

function TCert.GetIssuerO: string;
begin
  Result := CkToStr(CkCert_get_IssuerO(FHandle));
end;

function TCert.GetIssuerOU: string;
begin
  Result := CkToStr(CkCert_get_IssuerOU(FHandle));
end;

function TCert.GetIssuerS: string;
begin
  Result := CkToStr(CkCert_get_IssuerS(FHandle));
end;

function TCert.GetOcspUrl: string;
begin
  Result := CkToStr(CkCert_get_OcspUrl(FHandle));
end;

function TCert.GetPrivateKeyExportable: Boolean;
begin
  Result := Boolean(CkCert_get_PrivateKeyExportable(FHandle));
end;

function TCert.GetRevoked: Boolean;
begin
  Result := Boolean(CkCert_get_Revoked(FHandle));
end;

function TCert.GetRfc822Name: string;
begin
  Result := CkToStr(CkCert_get_Rfc822Name(FHandle));
end;

function TCert.GetSelfSigned: Boolean;
begin
  Result := Boolean(CkCert_get_SelfSigned(FHandle));
end;

function TCert.GetSerialNumber: string;
begin
  Result := CkToStr(CkCert_get_SerialNumber(FHandle));
end;

function TCert.GetSha1Thumbprint: string;
begin
  Result := CkToStr(CkCert_get_Sha1Thumbprint(FHandle));
end;

function TCert.GetSignatureVerified: Boolean;
begin
  Result := Boolean(CkCert_get_SignatureVerified(FHandle));
end;

function TCert.GetSubjectC: string;
begin
  Result := CkToStr(CkCert_get_SubjectC(FHandle));
end;

function TCert.GetSubjectCN: string;
begin
  Result := CkToStr(CkCert_get_SubjectCN(FHandle));
end;

function TCert.GetSubjectDN: string;
begin
  Result := CkToStr(CkCert_get_SubjectDN(FHandle));
end;

function TCert.GetSubjectE: string;
begin
  Result := CkToStr(CkCert_get_SubjectE(FHandle));
end;

function TCert.GetSubjectKeyId: string;
begin
  Result := CkToStr(CkCert_get_SubjectKeyId(FHandle));
end;

function TCert.GetSubjectL: string;
begin
  Result := CkToStr(CkCert_get_SubjectL(FHandle));
end;

function TCert.GetSubjectO: string;
begin
  Result := CkToStr(CkCert_get_SubjectO(FHandle));
end;

function TCert.GetSubjectOU: string;
begin
  Result := CkToStr(CkCert_get_SubjectOU(FHandle));
end;

function TCert.GetSubjectS: string;
begin
  Result := CkToStr(CkCert_get_SubjectS(FHandle));
end;

function TCert.GetTrustedRoot: Boolean;
begin
  Result := Boolean(CkCert_get_TrustedRoot(FHandle));
end;

function TCert.GetValidFromStr: string;
begin
  Result := CkToStr(CkCert_get_ValidFromStr(FHandle));
end;

function TCert.GetValidToStr: string;
begin
  Result := CkToStr(CkCert_get_ValidToStr(FHandle));
end;

function TCert.GetSerialDecimal: string;
begin
  Result := CkToStr(CkCert_get_SerialDecimal(FHandle));
end;

function TCert.GetSmartCardPin: string;
begin
  Result := CkToStr(CkCert_get_SmartCardPin(FHandle));
end;

procedure TCert.SetSmartCardPin(AValue: string);
begin
  CkCert_put_SmartCardPin(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TCert.GetSmartCardNoDialog: Boolean;
begin
  Result := Boolean(CkCert_get_SmartCardNoDialog(FHandle));
end;

procedure TCert.SetSmartCardNoDialog(AValue: Boolean);
begin
  CkCert_put_SmartCardNoDialog(FHandle, LongBool(AValue));
end;

function TCert.GetExtendedKeyUsage: string;
begin
  Result := CkToStr(CkCert_get_ExtendedKeyUsage(FHandle));
end;

function TCert.GetSubjectAlternativeName: string;
begin
  Result := CkToStr(CkCert_get_SubjectAlternativeName(FHandle));
end;

function TCert.GetUncommonOptions: string;
begin
  Result := CkToStr(CkCert_get_UncommonOptions(FHandle));
end;

procedure TCert.SetUncommonOptions(AValue: string);
begin
  CkCert_put_UncommonOptions(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TCert.GetSmartCardFailReason: Integer;
begin
  Result := CkCert_get_SmartCardFailReason(FHandle);
end;

function TCert.CheckRevoked: Integer;
begin
  Result := CkCert_CheckRevoked(FHandle);
end;

function TCert.ExportCertDerFile(const path: string): Boolean;
begin
  Result := Boolean(CkCert_ExportCertDerFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TCert.ExportCertPem: string;
begin
  Result := CkToStr(CkCert_ExportCertPem(FHandle));
end;

function TCert.ExportCertPemFile(const path: string): Boolean;
begin
  Result := Boolean(CkCert_ExportCertPemFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TCert.ExportCertXml: string;
begin
  Result := CkToStr(CkCert_ExportCertXml(FHandle));
end;

function TCert.ExportToPfxFile(const pfxFilename: string; const pfxPassword: string; bIncludeCertChain: Boolean): Boolean;
begin
  Result := Boolean(CkCert_ExportToPfxFile(FHandle, PAnsiChar(StrToCk(pfxFilename)), PAnsiChar(StrToCk(pfxPassword)), LongBool(bIncludeCertChain)));
end;

function TCert.FindIssuer: TChilkatBase;
begin
  Result := TChilkatBase.CreateFromHandle(CkCert_FindIssuer(FHandle));
end;

function TCert.GetEncoded: string;
begin
  Result := CkToStr(CkCert_GetEncoded(FHandle));
end;

function TCert.GetExtensionAsXml(const oid: string): string;
begin
  Result := CkToStr(CkCert_GetExtensionAsXml(FHandle, PAnsiChar(StrToCk(oid))));
end;

function TCert.GetPrivateKeyPem: string;
begin
  Result := CkToStr(CkCert_GetPrivateKeyPem(FHandle));
end;

function TCert.GetSpkiFingerprint(const hashAlg: string; const encoding: string): string;
begin
  Result := CkToStr(CkCert_GetSpkiFingerprint(FHandle, PAnsiChar(StrToCk(hashAlg)), PAnsiChar(StrToCk(encoding))));
end;

function TCert.HasPrivateKey: Boolean;
begin
  Result := Boolean(CkCert_HasPrivateKey(FHandle));
end;

function TCert.LoadByCommonName(const cn: string): Boolean;
begin
  Result := Boolean(CkCert_LoadByCommonName(FHandle, PAnsiChar(StrToCk(cn))));
end;

function TCert.LoadByEmailAddress(const emailAddress: string): Boolean;
begin
  Result := Boolean(CkCert_LoadByEmailAddress(FHandle, PAnsiChar(StrToCk(emailAddress))));
end;

function TCert.LoadByIssuerAndSerialNumber(const issuerCN: string; const serialNumber: string): Boolean;
begin
  Result := Boolean(CkCert_LoadByIssuerAndSerialNumber(FHandle, PAnsiChar(StrToCk(issuerCN)), PAnsiChar(StrToCk(serialNumber))));
end;

function TCert.LoadFromBase64(const encodedCert: string): Boolean;
begin
  Result := Boolean(CkCert_LoadFromBase64(FHandle, PAnsiChar(StrToCk(encodedCert))));
end;

function TCert.LoadFromFile(const path: string): Boolean;
begin
  Result := Boolean(CkCert_LoadFromFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TCert.LoadPem(const strPem: string): Boolean;
begin
  Result := Boolean(CkCert_LoadPem(FHandle, PAnsiChar(StrToCk(strPem))));
end;

function TCert.LoadPfxFile(const pfxPath: string; const password: string): Boolean;
begin
  Result := Boolean(CkCert_LoadPfxFile(FHandle, PAnsiChar(StrToCk(pfxPath)), PAnsiChar(StrToCk(password))));
end;

function TCert.PemFileToDerFile(const fromPath: string; const toPath: string): Boolean;
begin
  Result := Boolean(CkCert_PemFileToDerFile(FHandle, PAnsiChar(StrToCk(fromPath)), PAnsiChar(StrToCk(toPath))));
end;

function TCert.SaveToFile(const path: string): Boolean;
begin
  Result := Boolean(CkCert_SaveToFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TCert.SetFromEncoded(const encodedCert: string): Boolean;
begin
  Result := Boolean(CkCert_SetFromEncoded(FHandle, PAnsiChar(StrToCk(encodedCert))));
end;

function TCert.SetPrivateKey(privKey: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_SetPrivateKey(FHandle, privKey.Handle));
end;

function TCert.SetPrivateKeyPem(const privKeyPem: string): Boolean;
begin
  Result := Boolean(CkCert_SetPrivateKeyPem(FHandle, PAnsiChar(StrToCk(privKeyPem))));
end;

function TCert.UseCertVault(vault: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_UseCertVault(FHandle, vault.Handle));
end;

function TCert.VerifySignature: Boolean;
begin
  Result := Boolean(CkCert_VerifySignature(FHandle));
end;

function TCert.ExportToPfxBd(const password: string; includeCertChain: Boolean; pfxData: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_ExportToPfxBd(FHandle, PAnsiChar(StrToCk(password)), LongBool(includeCertChain), pfxData.Handle));
end;

function TCert.ExportCertDerBd(cerData: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_ExportCertDerBd(FHandle, cerData.Handle));
end;

function TCert.LoadPfxBd(pfxData: TChilkatBase; const password: string): Boolean;
begin
  Result := Boolean(CkCert_LoadPfxBd(FHandle, pfxData.Handle, PAnsiChar(StrToCk(password))));
end;

function TCert.LoadFromBd(certBytes: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_LoadFromBd(FHandle, certBytes.Handle));
end;

function TCert.HashOf(const part: string; const hashAlg: string; const encoding: string): string;
begin
  Result := CkToStr(CkCert_HashOf(FHandle, PAnsiChar(StrToCk(part)), PAnsiChar(StrToCk(hashAlg)), PAnsiChar(StrToCk(encoding))));
end;

function TCert.CheckSmartCardPin: Integer;
begin
  Result := CkCert_CheckSmartCardPin(FHandle);
end;

function TCert.X509PKIPathv1: string;
begin
  Result := CkToStr(CkCert_X509PKIPathv1(FHandle));
end;

function TCert.LoadFromSmartcard(const certSpec: string): Boolean;
begin
  Result := Boolean(CkCert_LoadFromSmartcard(FHandle, PAnsiChar(StrToCk(certSpec))));
end;

function TCert.LoadByThumbprint(const thumbprint: string; const encoding: string): Boolean;
begin
  Result := Boolean(CkCert_LoadByThumbprint(FHandle, PAnsiChar(StrToCk(thumbprint)), PAnsiChar(StrToCk(encoding))));
end;

function TCert.LoadBySubjectOid(const oid: string; const value: string): Boolean;
begin
  Result := Boolean(CkCert_LoadBySubjectOid(FHandle, PAnsiChar(StrToCk(oid)), PAnsiChar(StrToCk(value))));
end;

function TCert.GetSubjectPart(const partNameOrOid: string): string;
begin
  Result := CkToStr(CkCert_GetSubjectPart(FHandle, PAnsiChar(StrToCk(partNameOrOid))));
end;

function TCert.GetExtensionAsText(const oid: string): string;
begin
  Result := CkToStr(CkCert_GetExtensionAsText(FHandle, PAnsiChar(StrToCk(oid))));
end;

function TCert.GetPubKeyDer(preferPkcs1: Boolean; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_GetPubKeyDer(FHandle, LongBool(preferPkcs1), bd.Handle));
end;

function TCert.GetSignature(bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_GetSignature(FHandle, bd.Handle));
end;

function TCert.GetExtensionBd(const oid: string; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_GetExtensionBd(FHandle, PAnsiChar(StrToCk(oid)), bd.Handle));
end;

function TCert.LinkPkcs11(session: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_LinkPkcs11(FHandle, session.Handle));
end;

function TCert.UploadToCloud(jsonIn: TChilkatBase; jsonOut: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_UploadToCloud(FHandle, jsonIn.Handle, jsonOut.Handle));
end;

function TCert.SetCloudSigner(json: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_SetCloudSigner(FHandle, json.Handle));
end;

function TCert.IsRsa: Boolean;
begin
  Result := Boolean(CkCert_IsRsa(FHandle));
end;

function TCert.IsEcdsa: Boolean;
begin
  Result := Boolean(CkCert_IsEcdsa(FHandle));
end;

function TCert.Unload: Boolean;
begin
  Result := Boolean(CkCert_Unload(FHandle));
end;

function TCert.GetPrivateKey(privKey: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_GetPrivateKey(FHandle, privKey.Handle));
end;

function TCert.GetPublicKey(pubKey: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_GetPublicKey(FHandle, pubKey.Handle));
end;

function TCert.GetIssuer(issuer: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_GetIssuer(FHandle, issuer.Handle));
end;

function TCert.BuildCertChain(certChain: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCert_BuildCertChain(FHandle, certChain.Handle));
end;

initialization
  Chilkat_GetProcedureAddress(CkCert_Create,  'CkCert_Create');
  Chilkat_GetProcedureAddress(CkCert_Dispose, 'CkCert_Dispose');
  Chilkat_GetProcedureAddress(CkCert_SetAbortCheckCallback, 'CkCert_SetAbortCheckCallback');
  Chilkat_GetProcedureAddress(CkCert_SetPercentDoneCallback, 'CkCert_SetPercentDoneCallback');
  Chilkat_GetProcedureAddress(CkCert_SetProgressInfoCallback, 'CkCert_SetProgressInfoCallback');
  Chilkat_GetProcedureAddress(CkCert_get_LastErrorHtml, 'CkCert_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkCert_get_LastErrorText, 'CkCert_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkCert_get_LastErrorXml, 'CkCert_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkCert_get_Version, 'CkCert_get_Version');
  Chilkat_GetProcedureAddress(CkCert_get_DebugLogFilePath, 'CkCert_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkCert_put_DebugLogFilePath, 'CkCert_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkCert_get_VerboseLogging, 'CkCert_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkCert_put_VerboseLogging, 'CkCert_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkCert_get_LastMethodSuccess, 'CkCert_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkCert_put_LastMethodSuccess, 'CkCert_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkCert_get_AuthorityKeyId, 'CkCert_get_AuthorityKeyId');
  Chilkat_GetProcedureAddress(CkCert_get_AvoidWindowsPkAccess, 'CkCert_get_AvoidWindowsPkAccess');
  Chilkat_GetProcedureAddress(CkCert_put_AvoidWindowsPkAccess, 'CkCert_put_AvoidWindowsPkAccess');
  Chilkat_GetProcedureAddress(CkCert_get_CertVersion, 'CkCert_get_CertVersion');
  Chilkat_GetProcedureAddress(CkCert_get_Expired, 'CkCert_get_Expired');
  Chilkat_GetProcedureAddress(CkCert_get_ForClientAuthentication, 'CkCert_get_ForClientAuthentication');
  Chilkat_GetProcedureAddress(CkCert_get_ForCodeSigning, 'CkCert_get_ForCodeSigning');
  Chilkat_GetProcedureAddress(CkCert_get_ForSecureEmail, 'CkCert_get_ForSecureEmail');
  Chilkat_GetProcedureAddress(CkCert_get_ForServerAuthentication, 'CkCert_get_ForServerAuthentication');
  Chilkat_GetProcedureAddress(CkCert_get_ForTimeStamping, 'CkCert_get_ForTimeStamping');
  Chilkat_GetProcedureAddress(CkCert_get_IntendedKeyUsage, 'CkCert_get_IntendedKeyUsage');
  Chilkat_GetProcedureAddress(CkCert_get_IsRoot, 'CkCert_get_IsRoot');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerC, 'CkCert_get_IssuerC');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerCN, 'CkCert_get_IssuerCN');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerDN, 'CkCert_get_IssuerDN');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerE, 'CkCert_get_IssuerE');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerL, 'CkCert_get_IssuerL');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerO, 'CkCert_get_IssuerO');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerOU, 'CkCert_get_IssuerOU');
  Chilkat_GetProcedureAddress(CkCert_get_IssuerS, 'CkCert_get_IssuerS');
  Chilkat_GetProcedureAddress(CkCert_get_OcspUrl, 'CkCert_get_OcspUrl');
  Chilkat_GetProcedureAddress(CkCert_get_PrivateKeyExportable, 'CkCert_get_PrivateKeyExportable');
  Chilkat_GetProcedureAddress(CkCert_get_Revoked, 'CkCert_get_Revoked');
  Chilkat_GetProcedureAddress(CkCert_get_Rfc822Name, 'CkCert_get_Rfc822Name');
  Chilkat_GetProcedureAddress(CkCert_get_SelfSigned, 'CkCert_get_SelfSigned');
  Chilkat_GetProcedureAddress(CkCert_get_SerialNumber, 'CkCert_get_SerialNumber');
  Chilkat_GetProcedureAddress(CkCert_get_Sha1Thumbprint, 'CkCert_get_Sha1Thumbprint');
  Chilkat_GetProcedureAddress(CkCert_get_SignatureVerified, 'CkCert_get_SignatureVerified');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectC, 'CkCert_get_SubjectC');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectCN, 'CkCert_get_SubjectCN');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectDN, 'CkCert_get_SubjectDN');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectE, 'CkCert_get_SubjectE');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectKeyId, 'CkCert_get_SubjectKeyId');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectL, 'CkCert_get_SubjectL');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectO, 'CkCert_get_SubjectO');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectOU, 'CkCert_get_SubjectOU');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectS, 'CkCert_get_SubjectS');
  Chilkat_GetProcedureAddress(CkCert_get_TrustedRoot, 'CkCert_get_TrustedRoot');
  Chilkat_GetProcedureAddress(CkCert_get_ValidFromStr, 'CkCert_get_ValidFromStr');
  Chilkat_GetProcedureAddress(CkCert_get_ValidToStr, 'CkCert_get_ValidToStr');
  Chilkat_GetProcedureAddress(CkCert_get_SerialDecimal, 'CkCert_get_SerialDecimal');
  Chilkat_GetProcedureAddress(CkCert_get_SmartCardPin, 'CkCert_get_SmartCardPin');
  Chilkat_GetProcedureAddress(CkCert_put_SmartCardPin, 'CkCert_put_SmartCardPin');
  Chilkat_GetProcedureAddress(CkCert_get_SmartCardNoDialog, 'CkCert_get_SmartCardNoDialog');
  Chilkat_GetProcedureAddress(CkCert_put_SmartCardNoDialog, 'CkCert_put_SmartCardNoDialog');
  Chilkat_GetProcedureAddress(CkCert_get_ExtendedKeyUsage, 'CkCert_get_ExtendedKeyUsage');
  Chilkat_GetProcedureAddress(CkCert_get_SubjectAlternativeName, 'CkCert_get_SubjectAlternativeName');
  Chilkat_GetProcedureAddress(CkCert_get_UncommonOptions, 'CkCert_get_UncommonOptions');
  Chilkat_GetProcedureAddress(CkCert_put_UncommonOptions, 'CkCert_put_UncommonOptions');
  Chilkat_GetProcedureAddress(CkCert_get_SmartCardFailReason, 'CkCert_get_SmartCardFailReason');
  Chilkat_GetProcedureAddress(CkCert_CheckRevoked, 'CkCert_CheckRevoked');
  Chilkat_GetProcedureAddress(CkCert_ExportCertDerFile, 'CkCert_ExportCertDerFile');
  Chilkat_GetProcedureAddress(CkCert_ExportCertPem, 'CkCert_ExportCertPem');
  Chilkat_GetProcedureAddress(CkCert_ExportCertPemFile, 'CkCert_ExportCertPemFile');
  Chilkat_GetProcedureAddress(CkCert_ExportCertXml, 'CkCert_ExportCertXml');
  Chilkat_GetProcedureAddress(CkCert_ExportToPfxFile, 'CkCert_ExportToPfxFile');
  Chilkat_GetProcedureAddress(CkCert_FindIssuer, 'CkCert_FindIssuer');
  Chilkat_GetProcedureAddress(CkCert_GetEncoded, 'CkCert_GetEncoded');
  Chilkat_GetProcedureAddress(CkCert_GetExtensionAsXml, 'CkCert_GetExtensionAsXml');
  Chilkat_GetProcedureAddress(CkCert_GetPrivateKeyPem, 'CkCert_GetPrivateKeyPem');
  Chilkat_GetProcedureAddress(CkCert_GetSpkiFingerprint, 'CkCert_GetSpkiFingerprint');
  Chilkat_GetProcedureAddress(CkCert_HasPrivateKey, 'CkCert_HasPrivateKey');
  Chilkat_GetProcedureAddress(CkCert_LoadByCommonName, 'CkCert_LoadByCommonName');
  Chilkat_GetProcedureAddress(CkCert_LoadByEmailAddress, 'CkCert_LoadByEmailAddress');
  Chilkat_GetProcedureAddress(CkCert_LoadByIssuerAndSerialNumber, 'CkCert_LoadByIssuerAndSerialNumber');
  Chilkat_GetProcedureAddress(CkCert_LoadFromBase64, 'CkCert_LoadFromBase64');
  Chilkat_GetProcedureAddress(CkCert_LoadFromFile, 'CkCert_LoadFromFile');
  Chilkat_GetProcedureAddress(CkCert_LoadPem, 'CkCert_LoadPem');
  Chilkat_GetProcedureAddress(CkCert_LoadPfxFile, 'CkCert_LoadPfxFile');
  Chilkat_GetProcedureAddress(CkCert_PemFileToDerFile, 'CkCert_PemFileToDerFile');
  Chilkat_GetProcedureAddress(CkCert_SaveToFile, 'CkCert_SaveToFile');
  Chilkat_GetProcedureAddress(CkCert_SetFromEncoded, 'CkCert_SetFromEncoded');
  Chilkat_GetProcedureAddress(CkCert_SetPrivateKey, 'CkCert_SetPrivateKey');
  Chilkat_GetProcedureAddress(CkCert_SetPrivateKeyPem, 'CkCert_SetPrivateKeyPem');
  Chilkat_GetProcedureAddress(CkCert_UseCertVault, 'CkCert_UseCertVault');
  Chilkat_GetProcedureAddress(CkCert_VerifySignature, 'CkCert_VerifySignature');
  Chilkat_GetProcedureAddress(CkCert_ExportToPfxBd, 'CkCert_ExportToPfxBd');
  Chilkat_GetProcedureAddress(CkCert_ExportCertDerBd, 'CkCert_ExportCertDerBd');
  Chilkat_GetProcedureAddress(CkCert_LoadPfxBd, 'CkCert_LoadPfxBd');
  Chilkat_GetProcedureAddress(CkCert_LoadFromBd, 'CkCert_LoadFromBd');
  Chilkat_GetProcedureAddress(CkCert_HashOf, 'CkCert_HashOf');
  Chilkat_GetProcedureAddress(CkCert_CheckSmartCardPin, 'CkCert_CheckSmartCardPin');
  Chilkat_GetProcedureAddress(CkCert_X509PKIPathv1, 'CkCert_X509PKIPathv1');
  Chilkat_GetProcedureAddress(CkCert_LoadFromSmartcard, 'CkCert_LoadFromSmartcard');
  Chilkat_GetProcedureAddress(CkCert_LoadByThumbprint, 'CkCert_LoadByThumbprint');
  Chilkat_GetProcedureAddress(CkCert_LoadBySubjectOid, 'CkCert_LoadBySubjectOid');
  Chilkat_GetProcedureAddress(CkCert_GetSubjectPart, 'CkCert_GetSubjectPart');
  Chilkat_GetProcedureAddress(CkCert_GetExtensionAsText, 'CkCert_GetExtensionAsText');
  Chilkat_GetProcedureAddress(CkCert_GetPubKeyDer, 'CkCert_GetPubKeyDer');
  Chilkat_GetProcedureAddress(CkCert_GetSignature, 'CkCert_GetSignature');
  Chilkat_GetProcedureAddress(CkCert_GetExtensionBd, 'CkCert_GetExtensionBd');
  Chilkat_GetProcedureAddress(CkCert_LinkPkcs11, 'CkCert_LinkPkcs11');
  Chilkat_GetProcedureAddress(CkCert_UploadToCloud, 'CkCert_UploadToCloud');
  Chilkat_GetProcedureAddress(CkCert_SetCloudSigner, 'CkCert_SetCloudSigner');
  Chilkat_GetProcedureAddress(CkCert_IsRsa, 'CkCert_IsRsa');
  Chilkat_GetProcedureAddress(CkCert_IsEcdsa, 'CkCert_IsEcdsa');
  Chilkat_GetProcedureAddress(CkCert_Unload, 'CkCert_Unload');
  Chilkat_GetProcedureAddress(CkCert_GetPrivateKey, 'CkCert_GetPrivateKey');
  Chilkat_GetProcedureAddress(CkCert_GetPublicKey, 'CkCert_GetPublicKey');
  Chilkat_GetProcedureAddress(CkCert_GetIssuer, 'CkCert_GetIssuer');
  Chilkat_GetProcedureAddress(CkCert_BuildCertChain, 'CkCert_BuildCertChain');

end.
