(VBScript) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)
' The LoadFromFile method will automatically detect the file format..
set cert = CreateObject("Chilkat_9_5_0.Cert")
success = cert.LoadFromFile("qa_data/zatca/cert.pem")
If (success <> 1) Then
outFile.WriteLine(cert.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(cert.SubjectCN)
' Load the private key.
set privKey = CreateObject("Chilkat_9_5_0.PrivateKey")
success = privKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
If (success <> 1) Then
outFile.WriteLine(privKey.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Key Type: " & privKey.KeyType)
' Associate the private key with the certificate.
success = cert.SetPrivateKey(privKey)
If (success <> 1) Then
outFile.WriteLine(cert.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Success.")
outFile.Close
|