aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-05-26 21:44:58 -0400
committerDavid Bremner <david@tethera.net>2021-06-26 13:07:47 -0300
commit8c29a5da096b0314c6cca8889b740b79a9a548ed (patch)
tree4e967955f6f29c0b74d949fc90e18f8dc4a27ab4 /util
parent4b0c6fb2f1ba989fee554cb8fa2612046d6414a8 (diff)
cli/show: produce "email" element in sigstatus
When the certificate that signs a message is known to be valid, GMime is capable of reporting on the e-mail address embedded in the certificate. We pass this information along to the caller of "notmuch show", as often only the e-mail address of the certificate has actually been checked/verified. Furthermore, signature verification should probably at some point compare the e-mail address of the caller against the sender address of the message itself. Having to parse what gmime thinks is a "userid" to extract an e-mail address seems clunky and unnecessary if gmime already thinks it knows what the e-mail address is. See id:878s41ax6t.fsf@fifthhorseman.net for more motivation and discussion. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Diffstat (limited to 'util')
-rw-r--r--util/gmime-extra.c15
-rw-r--r--util/gmime-extra.h4
2 files changed, 19 insertions, 0 deletions
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 81a5b174..192cb078 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -108,6 +108,21 @@ g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
}
const char *
+g_mime_certificate_get_valid_email (GMimeCertificate *cert)
+{
+ /* output e-mail address only if validity is FULL or ULTIMATE. */
+ const char *email = g_mime_certificate_get_email(cert);
+
+ if (email == NULL)
+ return email;
+ GMimeValidity validity = g_mime_certificate_get_id_validity (cert);
+
+ if (validity == GMIME_VALIDITY_FULL || validity == GMIME_VALIDITY_ULTIMATE)
+ return email;
+ return NULL;
+}
+
+const char *
g_mime_certificate_get_fpr16 (GMimeCertificate *cert)
{
const char *fpr = g_mime_certificate_get_fingerprint (cert);
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 094309ec..889e91f3 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -69,6 +69,10 @@ gint64 g_mime_utils_header_decode_date_unix (const char *date);
* Return string for valid User ID (or NULL if no valid User ID exists)
*/
const char *g_mime_certificate_get_valid_userid (GMimeCertificate *cert);
+/**
+ * Return string for valid e-mail address (or NULL if no valid e-mail address exists)
+ */
+const char *g_mime_certificate_get_valid_email (GMimeCertificate *cert);
#ifdef __cplusplus
}