Decode/extract smime.p7m file contents (email with embedded files) with OpenSSL?

巧了我就是萌 提交于 2020-01-13 04:46:08

问题


We have an old process (VBScript) that reads a common mailbox and processes certain emails into a database.

New regulations have all messages with attachments now being digitally signed.

The process now only extracts one file (smime.p7m). Using a GUI-based viewer, I can see the embedded files and extract them with no problem. However, what I really need is a command-line based extracter that will write out the embedded files (PDFs, DOCs, XLSs) - they're not encrypted, just signed. I tested this by using a laptop that had no certificates and simply opened the smime.p7m file with the aforementioned viewer.

It looks like OpenSSL will decode/extract this and someone managed to get a version compiled on Windows. However, a lot of trial and error testing of the executable has been frustrating because I can't find the right combination of flags to just say "open the smime.p7m file and write out all the embedded files you find". "openssl smime" always seems to want a "cert.pem" after all the options and I haven't got that.

What am I missing? Thanks in advance.


回答1:


Did you try the "-noverify" option of openssl?

For a signed-only message, you can use "openssl smime -verify -in -noverify -out /tmp/blob"

Then you can use a RFC822-like parser to get the body and attachment(s) out of that "blob". That means that your parser has to be capable of encodings like quoted-printable and base64.




回答2:


Looks like the only available option is to write a simple program using Chilkat's library. This option costs $149 or $289, depending on what kind of license, per developer, but at least it's royalty-free.



来源:https://stackoverflow.com/questions/443580/decode-extract-smime-p7m-file-contents-email-with-embedded-files-with-openssl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!