DataFlex
DataFlex
Example: Crypt2.SetDecryptCert2 method
Demonstrates how to call the SetDecryptCert2 method. This example loads the certificate and private key from PEM files:PEM Format
Certificate file (cert.pem or cert.crt):
-----BEGIN CERTIFICATE----- MIID... (base64-encoded data) -----END CERTIFICATE-----
Private key file (key.pem or key.key):
-----BEGIN PRIVATE KEY----- MIIE... (base64-encoded data) -----END PRIVATE KEY-----
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vCert
Handle hoCert
Variant vPrivKey
Handle hoPrivKey
Handle hoCrypt
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadFromFile Of hoCert "c:/certs_and_keys/certAbc.pem" To iSuccess
// Assume success...
Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey
If (Not(IsComObjectCreated(hoPrivKey))) Begin
Send CreateComObject of hoPrivKey
End
Get ComLoadAnyFormatFile Of hoPrivKey "c:/certs_and_keys/certAbc_key.pem" To iSuccess
// Assume success...
Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
If (Not(IsComObjectCreated(hoCrypt))) Begin
Send CreateComObject of hoCrypt
End
Set ComCryptAlgorithm Of hoCrypt To "pki"
// ...
// ...
Get pvComObject of hoCert to vCert
Get pvComObject of hoPrivKey to vPrivKey
Get ComSetDecryptCert2 Of hoCrypt vCert vPrivKey To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCrypt To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Success."
End_Procedure