barbushin / php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
MIT License
1.67k stars 458 forks source link

[Feature Request] S/MIME decryption and verification #550

Open hrst opened 4 years ago

hrst commented 4 years ago

I understand that the project is called "php-imap" and adding S/MIME support would extend the scope of it, but I think that this would be a very worthwhile extension, as an encrypted message can contain the same parts (e.g. "text content", attachments, etc.) as a unencrypted message.

S/MIME support would mean adding both decrypting S/MIME-encrypted emails, as well as verifying S/MIME-signed emails. I'd love to a) either contribute this functionality or b) sponsoring/paying someone to add it to php-imap under MIT.

Has someone maybe worked on this already? Could you imaging adding this functionality to php-imap? My idea would be to 100% focus on decrypting/verifying. Key management should be left entirely to the users. This could be done by simply giving php-imap a way to add a function like retrieveKey(string $emailAddress) as a parameter. That way each user can implement "retrieveKey" themselves.

Decryption etc. can be done using the openssl_... functions such as openssl_pkcs7_decrypt. After decrypting, it should "reprocess" the message, as e.g. there might be attachments etc. as usual.

Sebbo94BY commented 3 years ago

Good point! The question is only, if it makes sense to add it directly here to this package or if we should outsource it.

Some readings regarding this topic: