Sample code for 30+ languages & platforms
VBScript

ZATCA Load Certificate and Private Key from PEM Files

See more ZATCA Examples

Demonstrates how to load a certificate and private key from a pair of PEM files.

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

' The LoadFromFile method will automatically detect the file format..
set cert = CreateObject("Chilkat.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.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