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

Get Public Key from Certificate PEM

See more Certificates Examples

Loads a certificate from a PEM file and gets the cert's public key.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
cert: HCkCert;
pubkey: HCkPublicKey;

begin
success := False;

cert := CkCert_Create();

success := CkCert_LoadFromFile(cert,'qa_data/certs/someCert.pem');
if (success = False) then
  begin
    Memo1.Lines.Add(CkCert__lastErrorText(cert));
    Exit;
  end;

//  Get the certificate's public key:
pubkey := CkPublicKey_Create();
CkCert_GetPublicKey(cert,pubkey);

Memo1.Lines.Add(CkPublicKey__getPem(pubkey,False));

//  OK.. we have the public key which can be used in other Chilkat classes/methods...

CkCert_Dispose(cert);
CkPublicKey_Dispose(pubkey);