B4X
B4X
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 B4X Downloads
Dim success As Boolean = False
' The LoadFromFile method will automatically detect the file format..
Dim cert As ChilkatCert
cert.Initialize("cert")
success = cert.LoadFromFile("qa_data/zatca/cert.pem")
If success <> True Then
Log(cert.LastErrorText)
Return
End If
Log(cert.SubjectCN)
' Load the private key.
Dim privKey As ChilkatPrivateKey
privKey.Initialize("privKey")
success = privKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
If success <> True Then
Log(privKey.LastErrorText)
Return
End If
Log("Key Type: " & privKey.KeyType)
' Associate the private key with the certificate.
success = cert.SetPrivateKey(privKey)
If success <> True Then
Log(cert.LastErrorText)
Return
End If
Log("Success.")