DataFlex
DataFlex
Duplicate OpensSSL Command that Decrypts Binary DER
See more OpenSSL Examples
This example duplicates the following:openssl smime -decrypt -in INPUT_FILE -inform der -binary -out OUTPUT_FILE -recip PEM_CERT_AND_KEY -passin pass:PRIVKEY_PASSWORD
Note: Although "smime" is the OpenSSL command, we're not really dealing with S/MIME. The arguments "-inform der -binary" indicate that the input is simply the binary DER (i.e. the PKCS7 binary encrypted object). The output can be any type of file (whatever was encrypted).
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoCrypt
Handle hoPem
Variant vPrivkey
Handle hoPrivkey
Variant vCert
Handle hoCert
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
If (Not(IsComObjectCreated(hoCrypt))) Begin
Send CreateComObject of hoCrypt
End
Set ComCryptAlgorithm Of hoCrypt To "pki"
Get Create (RefClass(cComChilkatPem)) To hoPem
If (Not(IsComObjectCreated(hoPem))) Begin
Send CreateComObject of hoPem
End
Get ComLoadPemFile Of hoPem "qa_data/pem/myPem.pem" "password" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoPem To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivkey
If (Not(IsComObjectCreated(hoPrivkey))) Begin
Send CreateComObject of hoPrivkey
End
Get pvComObject of hoPrivkey to vPrivkey
Get ComPrivateKeyAt Of hoPem 0 vPrivkey To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoPem To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get pvComObject of hoCert to vCert
Get ComCertAt Of hoPem 0 vCert To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoPem To sTemp1
Showln sTemp1
Procedure_Return
End
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
Get ComCkDecryptFile Of hoCrypt "qa_data/infile.enc" "qa_output/outfile.dat" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCrypt To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Success."
End_Procedure