From: David Bremner Date: Fri, 2 Jun 2017 23:57:01 +0000 (-0300) Subject: cli: make keyid from fingerprint in gmime 3.0 X-Git-Tag: 0.25_rc0~18 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=2b3224a6c4be6b6c038a9956448187e0a402687b cli: make keyid from fingerprint in gmime 3.0 The "key_id" field seems to used for userid in gmime-3.0, while the keyid is dropped in the fingerprint field if the full fingerprint is not available. --- diff --git a/notmuch-show.c b/notmuch-show.c index 311ac6ac..99475069 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -458,7 +458,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node) } } } else if (certificate) { - const char *key_id = g_mime_certificate_get_key_id (certificate); + const char *key_id = g_mime_certificate_get_fpr16 (certificate); if (key_id) { sp->map_key (sp, "keyid"); sp->string (sp, key_id); diff --git a/util/gmime-extra.c b/util/gmime-extra.c index 3c50a293..ed53e0ab 100644 --- a/util/gmime-extra.c +++ b/util/gmime-extra.c @@ -1,4 +1,5 @@ #include "gmime-extra.h" +#include GMimeStream * g_mime_stream_stdout_new() @@ -106,6 +107,15 @@ g_mime_utils_header_decode_date_unix (const char *date) { #else /* GMime >= 3.0 */ +const char* +g_mime_certificate_get_fpr16 (GMimeCertificate *cert) { + const char *fpr = g_mime_certificate_get_fingerprint (cert); + if (!fpr || strlen (fpr) < 16) + return fpr; + + return fpr + (strlen (fpr) - 16); +} + char * g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type) { diff --git a/util/gmime-extra.h b/util/gmime-extra.h index 7688129a..4407be33 100644 --- a/util/gmime-extra.h +++ b/util/gmime-extra.h @@ -14,6 +14,7 @@ GMimeStream *g_mime_stream_stdout_new(void); #define GMIME_ADDRESS_TYPE_BCC GMIME_RECIPIENT_TYPE_BCC #define g_mime_2_6_unref(obj) g_object_unref (obj) +#define g_mime_certificate_get_fpr16(cert) g_mime_certificate_get_key_id (cert) #else /* GMime >= 3.0 */ typedef GMimeAddressType GMimeRecipientType; @@ -56,6 +57,10 @@ typedef GMimeTrust GMimeCertificateTrust; #define g_mime_2_6_unref(obj) /*ignore*/ #endif +/** + * Get last 16 hex digits of fingerprint ("keyid") + */ +const char *g_mime_certificate_get_fpr16 (GMimeCertificate *cert); /** * Return the contents of the appropriate address header as a string * Should be freed using g_free