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

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCert
LOCAL oPubkey

nSuccess := 0

oCert := CreateObject("Chilkat.Cert")

nSuccess := oCert:LoadFromFile("qa_data/pem/my_cert.pem")
IF (nSuccess == 0)
    ? oCert:LastErrorText
    oCert:destroy()
    RETURN
ENDIF

oPubkey := CreateObject("Chilkat.PublicKey")
oCert:GetPublicKey(oPubkey)

//  Examine the public key as XML..
? oPubkey:GetXml()

oCert:destroy()
oPubkey:destroy()