Repository navigation
Open
Labels
Description
GMime 4.0 ideas:
- Privatize all object structs to allow for future expansion
- Rename
g_mime_object_encode()tog_mime_object_prepare()for API consistency with MimeKit? - Add a
GMimeVisitorclass andGMimeObjectClass::acceptvirtual method? If we do, we'll also want:- Add
GMimeMultipartAlternative - Add
GMimeMultipartRelated - Add
GMimeMultipartReport - Add
GMimeMessageDeliveryStatus - Add
GMimeMessageDispositionNotification - Add
GMimeTextRfc822Headers
- Add
- Add
g_mime_message_get_text_body()andg_mime_message_get_html_body()like MimeKit has? These would replaceg_mime_message_get_body() - Update
GMimeSignatureandGMimeCertificateto use agint64(internally at most) orGDateTime(public API for sure and maybe internally as well?) for the timestamps. (issue GMimeSignature created and expires are time_t, fail in Y2038 on platforms with 32-bit signed time_t #68 and issue in GMime 4.0, timestamps should use some sort of robust/native GLib representations #73) - Merge
GMimeDecryptFlagsandGMimeVerifyFlags(issue in GMime 4.0, consolidate GMimeVerifyFlags and GMimeDecryptFlags as GMimeCryptoFlags #70)? - Add support for
application/pkcs7-mime; smime-type=compressed-data(issue handle PKCS#7 CompressedData #66) - Add support for
application/pkcs7-mime; smime-type=authEnveloped-data(issue handle PKCS#7 authEnveloped-data #65)- Unfortunately, this seems to require GpgSM v2.5.20 and likely more like v2.5.24 to get it to actually work and I'm stuck on 2.4.8 as of Oct 28 2026.
-
Can we get rid ofg_mime_stream_close()? Disposing of the stream can (and already does to an extent) take the place ofclose(). This might eliminate confusion of reading/writing to a closed stream. -
Shouldg_mime_crypto_context_sign()take anInternetAddressMailboxinstead ofconst char *userid? Same idea forg_mime_crypto_context_encrypt()for both theuseridandrecipientsarguments. - Should
g_mime_object_write_to_stream()be fixed to returngint64? -
ShouldGMimeStream's read/write functions takeGErrorand/orGCancellationarguments? Same forGMimeParserAPIs? Andg_mime_object_write_to_stream(), etc.
Activity
jstedfast commentedon Dec 21, 2019
The more I think about it, the more I think I'm probably going to pass on adding a GMimeVisitor API.
I'm probably also going to pass on the GError and GCancellation stuff as well.
albrechtd commentedon Dec 30, 2019
Disclaimer: the remarks below come from the requirements for Balsa as well as for an other project (non-FOSS) I'm working on for my current employer (a German Government agency) which has somewhat different requirements as it is not a MUA.
Basically, GMime 3.2.4 (the latest for Debian Bullseye) provides almost everything I need – the exception actually is crypto support. From my POV, it would be ideal if GMime would simply provide access to the excellent GpgME data structures. I understand that you want to hide all the complexity of GpgME behind your own interfaces for a painless implementation of trivial use-cases. However, as this approach also completely hides the full flexibility and power of GpgME, the GMime crypto interface is not usable for more complex tasks like mine.
I presume you want to keep your stripped-down crypto interface in ver 4.0 as to support other projects. In order to make is usable for more demanding use cases, a solution could be adding methods to access to the underlying GpgME objects, plus several callbacks and/or signals. If you want to avoid a mandatory dependency of GMime headers on gpgme.h, you could wrap the “advanced” interfaces into
#ifdef GPGME_VERSION, i.e. they are visible only if gpgme.h is included before.1. GpgME context manipulation
GMime provides no access to the properties of the underlying GpgME contexts and is thus unusable for me. It must be possible to configure the crypto engine, including the working folder, flags, etc., plus some more nasty changes of the engine. A method for accessing the GpgME context, e.g.
gpgme_ctx_t g_mime_crypto_context_gpgme_ctx(GMimeCryptoContext *ctx), should be sufficient. If a context is created automatically (e.g. forg_mime_multipart_signed_verify()or similar) a callback must be called (or a signal fired) immediately after creating the context. The callback (or signal handler) must receive the GpgME context and the purpose it has been created for.2. Key selection for signing and/or encryption
If I understand the key selection code correctly, it simply returns the first matching key on success, or just bails out with an error. This would be fine in a perfectly ideal world, but fails for the following common cases and is thus not usable:
As solution, GMime's key listing must call a callback with a list of keys (i.e.
gpgme_key_t) and the reason for calling it (see the Balsa code for an example). The list shall containFurthermore, the key listing mode and properties of the context must be configurable, but this would be covered by solving item 1 above.
BTW, a key selection based upon
InternetAddressMailboxitems is really a very bad idea: a typical use case is to configure the key id (instead of the mail address) in user profiles as to force using a specific key, which would of course be impossible when requiringInternetAddressMailboxarguments.3. Key properties
The access to (sub-) key properties in the GMime interface (“GMimeCertificate”) is extremely limited. In my projects, I must have access
is_de_vs(German Government classified at “Restricted” level = “VS-NfD”),Note that this information is required both for key listings (i.e. in the callback outlined above), and for decryption and signature verification data.
Providing access to the GpgME data via a method, e.g.
const gpgme_key_t g_mime_certificate_gpgme_key(GMimeCertificate *cert), should be sufficient.4. Signature verification info
The signature information provided by GMime is incomplete and therefore unusable for me. Access to in particular the PKA data, chain model information, notation and policy data is required. Again, a method like
const gpgme_verify_result_t g_mime_signature_gpgme_result(GMimeSignature *sig)should be sufficient.5. Decryption result
The decryption result lacks the flags (e.g. VS-NfD, see item 3 above). Please provide access to the full data, e.g.
const gpgme_decrypt_result_t g_mime_decrypt_result_gpgme_result(GMimeDecryptResult *result)or similar.Note: the following points are not blockers, but more a wish list. I have implementations for them (using my own GpgME interface, of course), but they might also be of interest for other projects.
6. RFC 4880 messages
It would be great if GMime could provide support for “old” RFC 4880 signed and/or encrypted messages. For sending, this should be limited to just signing and/or encrypting a single-part (text/plain) message.
The interpretation of such parts is a lot more complex, as a message part may contain a mixture of signed and/or encrypted and unsigned/unencrypted data. A common case are mailing list processors which append a few lines of information after the signed stuff, but it is also a method used in attacks (see the Johnny, you are fired! and Re: What's Up Johnny? papers). A method interpreting such message parts therefore should return a list of chunks, e.g. for the simple mailing list example a text “part” with signature information (the original message), plus a text “part” without it (the stuff appended by the list processor).
7. Autocrypt keys via key id or mailbox
The Autocrypt code is very nice, but it would be great if I could have a method which loads the minimal key (as requested by the Autocrypt specs) based upon the key id (or mail address, but see the remark about
InternetAddressMailboxabove), e.g.void g_mime_autocrypt_header_set_keydata_by_id(GMimeAutocryptHeader *ah, const gchar *key_id). However, exporting the minimal key is a little tricky, as it is not supported directly by GpgME, and depends upon the underlying gpg version (see the Enigmail or Balsa sources).8. Standards compliance
I believe that GMime is really well-tested and documented. However, for including GMime in (non-FOSS) projects requiring formal approvals it would be helpful if you could prove that GMime complies with usual safety/security standards like MISRA C:2012 or the SEI CERT C Coding Standard, i.e. if you could provide a test/compliance report from a tool like Flexelint, LDRA or similar – typically not in the toolbox of OSS programmers, though, so this is really a “nice-to-have” topic.
bernhardreiter commentedon Mar 3, 2020
Would be cool to have support for getting pubkey with https://gnupg.org/WKD (Web key directory).
It probably just works already when setting the right gpgme options for external key listings, but some examples would be helpful.
sigasigasiga commentedon Oct 7, 2021
it could be nice to add an ability to copy
GMimeObjectclass. AFAIK it couldn't be implemented in 3.x because of ABI breakage https://www.mail-archive.com/gmime-devel-list@gnome.org/msg00506.htmlgouthamkrishnakv commentedon Dec 5, 2022
Is there a plan to move to Meson or CMake?
Most GNOME applications do use Meson, and I was thinking of writing meson build files to integrate it into my project. Automake seemed to be difficult and cumbersome for my use-case, and so this might probably make it easier to integrate it later on for future projects, also.
jstedfast commentedon Dec 5, 2022
@gauthamkrishna9991 I haven't been keeping up with GNOME development trends for quite a while so haven't even heard of Meson and I haven't used CMake enough to have an opinion on that (although I have at least heard of it).
gouthamkrishnakv commentedon Dec 7, 2022
@jstedfast Okay, cool cool. I'll probably have to look into integrating Autotools into my project, then. I was thinking maybe you could check this out for a major version bump, as this would be a good time to check out meson itself.
Just to give you an idea, this is how a
meson.buildfile looks like (in project root).In any case, I'll end up checking for Autotools integration for my personal project, as that seems to be your preference.
c-alpha commentedon Jan 11, 2023
In https://github.com/astroidmail/astroid we migrated from meson to CMake. Automake is certainly showing its age. That said, my recommendation would be to go with CMake.
A suggestion for how new crypto callback system
dagle commentedon May 10, 2023
Refcounted format and parser options.
Atm these boxed types are then copied multiple times when used.
I propose that we should reference count these object instead of copying.
If a user wants to pull out parser from a structure, change a values without wanting it propagated,
a g_mime_(format|parser)_options_copy should be used (which already exists for format).
It also simplifies the semantics for callbacks and NotifyDestroy, since copy wouldn't
copy the callback and clone (ref) would just increase a reference counter.
These change need to be stated in the doc strings and changing the clone/free to ref/unref
should also make it more clear what is going on.
I have written a test version with these changes and I haven't run into any problems so far.
jstedfast commentedon Aug 31, 2023
@dagle
The reason they are cloned instead of ref-counted is because GMimeHeader (and other objects that keep refs to them) need to be sure they haven't changed since they were referenced.
jstedfast commentedon Oct 28, 2026
@gouthamkrishnakv My v4.0-dev branch has moved to Meson.
jstedfast commentedon Oct 29, 2026
@albrechtd
I've added ways to get access to the gpgme_x_t types:
Let's figure out a solution for this.
Yep. See the new g_mime_certificate_get_gpgme_key() function.
Yes, this is a good idea - I'll look into adding this for v4.0.
Sure.
GMime has had detection for this, but yea, it's kind of a pain. I'll see if I can figure something out.
@dkg implemented Autocrypt for GMime. I know very little about it, but I'm open to API suggestions.
I think I saw something about an Autocrypot v2 spec being worked on?
That's gonna be hard....
albrechtd commentedon Oct 30, 2026
Hmmm, to be honest, I still don't understand why you basically wrap parts of the GpgME interface (which has everything required) into an extra layer of complexity which enlarges the code, adds chances for bugs, and supports just the very basic operations, i.e. requires to expose the underlying interfaces for any non-trivial use case anyway. IMHO, using the GpgME interface directly would be by far more flexible and straightforward.
Returning the context as
void *in a public interface which the caller is expected to cast is a really bad idea which may lead to all sorts of nasty bugs (see e.g. MISRA C, Rule 11.5). The return value must be agpgme_ctx_t!Furthermore, it doesn't make sense to have two methods returning the
gpgme_ctx_t– the latter includes thegpgme_protocol_t, so if you really want to keep the extra complexity (which I strongly discourage) the parent object should be used.GpgME has everything for writing a proper callback function. Use the GpgME stuff verbatim, and you're done.
Same flaw as above - the return value must be a
gpgme_key_t! Again, I cannot see any good reason for re-inventing a rather limited version of GpgME's key management.Again, GpgME has everything…
…ditto.
Unfortunately, I still see lots of RFC 9580 (was '4880) stuff in the wild, so this would be really helpful.
An other very interesting extension would be support for RFC 9788 protected headers, btw – afaik not widely (if at all) used yet, though. Thunderbird seems to support a meanwhile withdrawn proposal in some versions; an interesting approach, but not worth implementing any more IMHO.
Good question… I'm not aware of that. Do you have any pointers?
Well, even a rather simple static analyser like cppcheck can detect lots of issues. Access to a more sophisticated tool like LDRA, Eclair, PClint Plus, … would of course be helpful. IMHO, implementing the rules and recommendations of the C CERT Secure Coding Standard would be an excellent starting point!
jstedfast commentedon Oct 30, 2026
@albrechtd
The original idea was to abstract things out so a different backend could be used. Given that it's not super likely, I could possibly remove the abstraction layer.
I'll look into something like cppcheck.
jstedfast commentedon Oct 30, 2026
@albrechtd FWIW, I've been working on adding fuzz tests and as part of my port of to Meson, I now have unit tests running under ASan and UBSan and things are coming back clean.
jstedfast commentedon Oct 30, 2026
@albrechtd I've added CodeQL and cppcheck GitHub workflows now.
jstedfast commentedon Oct 30, 2026
@albrechtd Ripping out the GMime abstractions over gpgme_ctx_t was fairly quick & doable and I just pushed that. I'm working on implementing inline PGP support now using the existing OpenPGP filter logic.
jstedfast commentedon Oct 30, 2026
@albrechtd Inline-PGP support has been added
jstedfast commentedon Oct 30, 2026
@dagle I've decided you were right to suggest ref counting GMimeFormatOptions and GMimeParserOptions - I'm going to keep the clone API as well, to satisfy the needs I have, but that doesn't mean we can't ref-count them.