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

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
pkey: HCkPrivateKey;
pubKey: HCkPublicKey;

begin
success := False;

pkey := CkPrivateKey_Create();

//  Load the private key from an PEM file:
success := CkPrivateKey_LoadPemFile(pkey,'private.pem');
if (success = False) then
  begin
    Memo1.Lines.Add(CkPrivateKey__lastErrorText(pkey));
    Exit;
  end;

pubKey := CkPublicKey_Create();
CkPrivateKey_ToPublicKey(pkey,pubKey);

success := CkPublicKey_SavePemFile(pubKey,False,'pubKey.pem');
if (success <> True) then
  begin
    Memo1.Lines.Add(CkPublicKey__lastErrorText(pubKey));
    CkPublicKey_Dispose(pubKey);
    Exit;
  end;

Memo1.Lines.Add('Success.');

CkPrivateKey_Dispose(pkey);
CkPublicKey_Dispose(pubKey);