(AutoIt) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
; The LoadFromFile method will automatically detect the file format..
$oCert = ObjCreate("Chilkat.Cert")
Local $bSuccess = $oCert.LoadFromFile("qa_data/zatca/cert.pem")
If ($bSuccess <> True) Then
ConsoleWrite($oCert.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($oCert.SubjectCN & @CRLF)
; Load the private key.
$oPrivKey = ObjCreate("Chilkat.PrivateKey")
$bSuccess = $oPrivKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
If ($bSuccess <> True) Then
ConsoleWrite($oPrivKey.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Key Type: " & $oPrivKey.KeyType & @CRLF)
; Associate the private key with the certificate.
$bSuccess = $oCert.SetPrivateKey($oPrivKey)
If ($bSuccess <> True) Then
ConsoleWrite($oCert.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Success." & @CRLF)
|