Sample code for 30+ languages & platforms
Delphi DLL

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
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Cert, PublicKey;

...

procedure TForm1.Button1Click(Sender: TObject);
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);

end;