Sample code for 30+ languages & platforms
VBScript

Get Certificate's Public Key

Loads a certificate from PEM and gets the 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")

strPem = "-----BEGIN CERTIFICATE----- ..."

success = cert.LoadPem(strPem)
If (success = 0) Then
    outFile.WriteLine(cert.LastErrorText)
    WScript.Quit
End If

set pubKey = CreateObject("Chilkat.PublicKey")
success = cert.GetPublicKey(pubKey)

' You can now use the public key object however it is needed,
' and access its various properties and methods..

outFile.WriteLine(pubKey.GetXml())

outFile.Close