PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Crypt
oleobject loo_Pem
oleobject loo_Privkey
oleobject loo_Cert
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")
if li_rc < 0 then
destroy loo_Crypt
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Crypt.CryptAlgorithm = "pki"
loo_Pem = create oleobject
li_rc = loo_Pem.ConnectToNewObject("Chilkat.Pem")
li_Success = loo_Pem.LoadPemFile("qa_data/pem/myPem.pem","password")
if li_Success = 0 then
Write-Debug loo_Pem.LastErrorText
destroy loo_Crypt
destroy loo_Pem
return
end if
loo_Privkey = create oleobject
li_rc = loo_Privkey.ConnectToNewObject("Chilkat.PrivateKey")
li_Success = loo_Pem.PrivateKeyAt(0,loo_Privkey)
if li_Success = 0 then
Write-Debug loo_Pem.LastErrorText
destroy loo_Crypt
destroy loo_Pem
destroy loo_Privkey
return
end if
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")
li_Success = loo_Pem.CertAt(0,loo_Cert)
if li_Success = 0 then
Write-Debug loo_Pem.LastErrorText
destroy loo_Crypt
destroy loo_Pem
destroy loo_Privkey
destroy loo_Cert
return
end if
li_Success = loo_Crypt.SetDecryptCert2(loo_Cert,loo_Privkey)
if li_Success = 0 then
Write-Debug loo_Crypt.LastErrorText
destroy loo_Crypt
destroy loo_Pem
destroy loo_Privkey
destroy loo_Cert
return
end if
li_Success = loo_Crypt.CkDecryptFile("qa_data/infile.enc","qa_output/outfile.dat")
if li_Success = 0 then
Write-Debug loo_Crypt.LastErrorText
destroy loo_Crypt
destroy loo_Pem
destroy loo_Privkey
destroy loo_Cert
return
end if
Write-Debug "Success."
destroy loo_Crypt
destroy loo_Pem
destroy loo_Privkey
destroy loo_Cert