Sample code for 30+ languages & platforms
VBScript

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 VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

set cert = CreateObject("Chilkat.Cert")

success = cert.LoadFromFile("qa_data/certs/someCert.pem")
If (success = 0) Then
    outFile.WriteLine(cert.LastErrorText)
    WScript.Quit
End If

' Get the certificate's public key:
set pubkey = CreateObject("Chilkat.PublicKey")
success = cert.GetPublicKey(pubkey)

outFile.WriteLine(pubkey.GetPem(0))

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

outFile.Close