(VBScript) Get Certificate's Public Key
Loads a certificate from PEM and gets the public key.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Cert")
set cert = CreateObject("Chilkat.Cert")
strPem = "-----BEGIN CERTIFICATE----- ..."
success = cert.LoadPem(strPem)
If (success <> 1) Then
outFile.WriteLine(cert.LastErrorText)
WScript.Quit
End If
' pubKey is a Chilkat.PublicKey
Set pubKey = cert.ExportPublicKey()
If (cert.LastMethodSuccess = 0) Then
outFile.WriteLine(cert.LastErrorText)
WScript.Quit
End If
' 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
|