Discussion:
How to decrypt smime.p7m file in DER format using OpenSSL in C code.
Yash Dosi
2014-06-05 11:51:09 UTC
Permalink
Hi All,

I am trying to decrypt emails using openssl.

I am getting smime.p7m file from the server. But it is in DER format.

I can decrypt this file using command prompt, with the command

openssl smime -decrypt -in openssl_working_smime.p7m -inform DER
-inkey mycert.pem > dec_mail.eml

But now I want to do this using C code.

Right now I am trying to do using -

SMIME_read_PKCS7()

But this returns null with

SMIME_read_ASN1:no content type:asn_mime.c:451:

error

Any ideas how to do it?
Vladimir Zatsepin
2014-06-05 12:52:31 UTC
Permalink
Hi,

To load a DER-encoded PKCS7 structure from the file you have to
use d2i_PKCS7_bio() function.
Post by Yash Dosi
Hi All,
I am trying to decrypt emails using openssl.
I am getting smime.p7m file from the server. But it is in DER format.
I can decrypt this file using command prompt, with the command
openssl smime -decrypt -in openssl_working_smime.p7m -inform DER -inkey mycert.pem > dec_mail.eml
But now I want to do this using C code.
Right now I am trying to do using -
SMIME_read_PKCS7()
But this returns null with
error
Any ideas how to do it?
Loading...