Hi,
I am trying to recieve an encrypted email attachment and then decrypt the attachment using open ssl. I am successful in decrypting the file. The file that I recieve is in smime.p7m extension. When I decrypt that file the file is decrypted and the file that is decrypted displays the data into base64 encoded data with the following headers.

MIME-Version: 1.0
Content-Type: multipart/mixed; 

Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Message test
Content-Type: text/xml; name=Abc.xml
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=Abc.xml

And the data beneath this header is base 64 encoded. Now what I want to achieve is that I should be able to convert the file in Abc.xml directly with the xml data displaying in it. How can I achieve this. I am mentioning the openssl commands that I am using for decrypting the file.

openssl smime -decrypt -in smime.p7m -inform DER -inkey privkey.pem -out GHI.xml

Thanks in advance.

Maybe you can add the base64 option to the openssl command, unfortunately I cannot try right now but follow this:

otherwise you can use base64 command from the command line:

base64 --decode source.txt > Abc.xml

But in this last case, as with base64_decode() in PHP, you have to remove the headers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.