(Xojo Plugin) 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..
Dim cert As New Chilkat.Cert
Dim success As Boolean
success = cert.LoadFromFile("qa_data/zatca/cert.pem")
If (success <> True) Then
System.DebugLog(cert.LastErrorText)
Return
End If
System.DebugLog(cert.SubjectCN)
// Load the private key.
Dim privKey As New Chilkat.PrivateKey
success = privKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
If (success <> True) Then
System.DebugLog(privKey.LastErrorText)
Return
End If
System.DebugLog("Key Type: " + privKey.KeyType)
// Associate the private key with the certificate.
success = cert.SetPrivateKey(privKey)
If (success <> True) Then
System.DebugLog(cert.LastErrorText)
Return
End If
System.DebugLog("Success.")
|