From 592a3695a573ca5e0a1fa45b79b8a0e64225f1d9 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 25 Aug 2015 21:58:24 +0100 Subject: [PATCH] PGP: Do not save contact's fingerprint when no key found --- src/pgp/gpg.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index 9d594be4..3067f81d 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -196,7 +196,7 @@ p_gpg_addkey(const char * const jid, const char * const keyid) } gpgme_key_t key = NULL; - error = gpgme_get_key(ctx, keyid, &key, 1); + error = gpgme_get_key(ctx, keyid, &key, 0); gpgme_release(ctx); if (error || key == NULL) { @@ -406,8 +406,16 @@ p_gpg_verify(const char * const barejid, const char *const sign) gpgme_verify_result_t result = gpgme_op_verify_result(ctx); if (result) { if (result->signatures) { - log_debug("Fingerprint found for %s: %s ", barejid, result->signatures->fpr); - g_hash_table_replace(fingerprints, strdup(barejid), strdup(result->signatures->fpr)); + gpgme_key_t key = NULL; + error = gpgme_get_key(ctx, result->signatures->fpr, &key, 0); + if (error) { + log_debug("Could not find PGP key with ID %s for %s", result->signatures->fpr, barejid); + } else { + log_debug("Fingerprint found for %s: %s ", barejid, key->subkeys->fpr); + g_hash_table_replace(fingerprints, strdup(barejid), strdup(key->subkeys->fpr)); + } + + gpgme_key_unref(key); } }