DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoCert
Variant vPrivKey
Handle hoPrivKey
String sTemp1
Move False To iSuccess
// The LoadFromFile method will automatically detect the file format..
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadFromFile Of hoCert "qa_data/zatca/cert.pem" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSubjectCN Of hoCert To sTemp1
Showln sTemp1
// Load the private key.
Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey
If (Not(IsComObjectCreated(hoPrivKey))) Begin
Send CreateComObject of hoPrivKey
End
Get ComLoadPemFile Of hoPrivKey "qa_data/zatca/ec-secp256k1-priv-key.pem" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoPrivKey To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComKeyType Of hoPrivKey To sTemp1
Showln "Key Type: " sTemp1
// Associate the private key with the certificate.
Get pvComObject of hoPrivKey to vPrivKey
Get ComSetPrivateKey Of hoCert vPrivKey To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Success."
End_Procedure