[Patch] fix broken decryption of s/mime messages loaded from imap

Albrecht Dreß <[email protected]>
Newsgroups gmane.comp.gnome.apps.balsa
Message-ID <[email protected]>
Hi all,

at work, I use Balsa with IMAP, and many of our messages are s/mime encrypted, using the RFC 5751 application/pkcs7-mime “enveloped-data” media type.  In this case, the top-level content type of the message is application/pkcs7-mime, and the body is just a single part containing the encrypted matter.

With messages on IMAP (with caching enabled), I saw the following effect:

1. select a not too small encrypted message, and click decrypt: decryption fails.  The Gpgme debug log shows that no data is fed into gpgsm;
2. select “Message ▶ View Source…”: shows the base64 encoded encrypted body of the message.  Feeding the data from the dialogue through base64 and gpgsm decrypts properly;
3. again click decrypt on the message: fails again;
4. select an other message in the same IMAP mailbox, and then again the one from step 1: now decryption is successful (data loaded from the cache?);
5. terminate Balsa, erase the cache ( ~/.balsa/imap-cache/*), start balsa again, and select the message from step 1: decryption fails.

Apparently, Balsa does not properly load the message content if the message is a single-part application/pkcs7-mime message.  Afaict, all multipart messages, including multipart/encrypted and multipart/signed, are loaded properly.

After digging through the code, I /think/ the problem is in libbalsa_mailbox_imap_fetch_structure() which loads only text/* and short messages completely (to be honest, I don't understand why multipart/* is working, though…).  At least, the attached trivial patch, just loading single-part S/MIME messages just as text/*, solves the issue for me.

Any insight would be highly appreciated!

Cheers,
Albrecht.

_______________________________________________
balsa-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/balsa-list
fix_smime_imap_loading.diff (text/x-patch, 788 B)
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index d85e377c1..1abaa12a0 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -2247,7 +2247,8 @@ libbalsa_mailbox_imap_fetch_structure(LibBalsaMailbox *mailbox,
        LIBBALSA_MESSAGE_GET_LENGTH(message)<8192 ||
        (message->headers &&
         (!message->headers->content_type ||
-         g_mime_content_type_is_type(message->headers->content_type, "text", "*"))) ){
+         g_mime_content_type_is_type(message->headers->content_type, "text", "*") ||
+		 g_mime_content_type_is_type(message->headers->content_type, "application", "pkcs7-mime")))) {
         /* we could optimize this part a little bit: we do not need to
          * keep reopening the stream. */
         GMimeStream *stream =
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEEcCEPemLFTtyGf4zATKlvDmfn2fgFAlxdwe0ACgkQTKlvDmfn
2fiDIwgAggZKuVRIWSDbO9UwwzLB0UZNPyKhWVFND6vxxvHvmEoiC/WLm/5/4xnX
vCkUa6o9ur5RdpDeHwEIzHV5omoJCmMU8ngO4ElrzT+ZZRaTuXaRIXtJQBqyCz7S
YmZJzieue70MCoqU1Z22AzRFko8mySRA4bSxhEj1oncG25Ea10XgobPKLzU9UukU
qrxchFTdKRb3oGCP0ZLV6NHsPbM/umMGOsHbPDb+2R+66u2G2iIl0N4ZosuRb0Wi
vyZ5a9au4jAjebwSX7gExxHSPkQSuNqMKlnXKyhL7eKh2myap1tr6KxDZNgrgmr0
rAcCCdeqpjw6Xxm/je7w7AuPPIT/1w==
=nkD9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.