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.
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 = 

Attachment: pgpyWK_7YhuuJ.pgp
Description: PGP signature

_______________________________________________
balsa-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/balsa-list

Reply via email to