(Delphi ActiveX) Get Certificate's Public Key
Loads a certificate from PEM and gets the public key. Note: This example requires Chilkat v11.0.0 or greater.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
cert: TChilkatCert;
strPem: WideString;
pubKey: TPublicKey;
begin
success := 0;
cert := TChilkatCert.Create(Self);
strPem := '-----BEGIN CERTIFICATE----- ...';
success := cert.LoadPem(strPem);
if (success = 0) then
begin
Memo1.Lines.Add(cert.LastErrorText);
Exit;
end;
pubKey := TPublicKey.Create(Self);
cert.GetPublicKey(pubKey.ControlInterface);
// You can now use the public key object however it is needed,
// and access its various properties and methods..
Memo1.Lines.Add(pubKey.GetXml());
end;
|