(Visual FoxPro) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
LOCAL loCert
LOCAL lnSuccess
LOCAL loPrivKey
* The LoadFromFile method will automatically detect the file format..
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert')
loCert = CreateObject('Chilkat.Cert')
lnSuccess = loCert.LoadFromFile("qa_data/zatca/cert.pem")
IF (lnSuccess <> 1) THEN
? loCert.LastErrorText
RELEASE loCert
CANCEL
ENDIF
? loCert.SubjectCN
* Load the private key.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.PrivateKey')
loPrivKey = CreateObject('Chilkat.PrivateKey')
lnSuccess = loPrivKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
IF (lnSuccess <> 1) THEN
? loPrivKey.LastErrorText
RELEASE loCert
RELEASE loPrivKey
CANCEL
ENDIF
? "Key Type: " + loPrivKey.KeyType
* Associate the private key with the certificate.
lnSuccess = loCert.SetPrivateKey(loPrivKey)
IF (lnSuccess <> 1) THEN
? loCert.LastErrorText
RELEASE loCert
RELEASE loPrivKey
CANCEL
ENDIF
? "Success."
RELEASE loCert
RELEASE loPrivKey
|