# HG changeset patch # User Sven Gaerner # Date 1422820522 -3600 # Node ID fec172dbacc79ad33d5089f874a7cfb281f88603 # Parent 527ba1c1873ed3c15d1f71f96182bfeaeb4efc8a Check all signatures and stop immediately if one could be verified diff -r 527ba1c1873e -r fec172dbacc7 mcabber/mcabber/pgp.c --- a/mcabber/mcabber/pgp.c Sun Oct 11 17:20:29 2015 +0200 +++ b/mcabber/mcabber/pgp.c Sun Feb 01 20:55:22 2015 +0100 @@ -262,19 +262,26 @@ if (!err) { gpgme_verify_result_t vr = gpgme_op_verify_result(ctx); if (vr && vr->signatures) { - char *r = vr->signatures->fpr; - // Found the fingerprint. Let's try to get the key id. - if (!gpgme_get_key(ctx, r, &key, 0) && key) { - r = key->subkeys->keyid; - gpgme_key_release(key); - } - // r is a static variable, let's copy it. - verified_key = g_strdup(r); - *sigsum = vr->signatures->summary; - // For some reason summary could be 0 when status is 0 too, - // which means the signature is valid... - if (!*sigsum && !vr->signatures->status) - *sigsum = GPGME_SIGSUM_GREEN; + gpgme_signature_t s = NULL; + // check all signatures and stop if the first could be verified + for (s = vr->signatures; + (s != NULL) && (verified_key != NULL); + s = s->next) { + // Found the fingerprint. Let's try to get the key id. + if (NULL != s->fpr) { + if (!gpgme_get_key(ctx, s->fpr, &key, 0)) { + if (key) { + verified_key = g_strdup(key->subkeys->keyid); + gpgme_key_release(key); + } + } + } + *sigsum = s->summary; + // For some reason summary could be 0 when status is 0 too, + // which means the signature is valid... + if ((!*sigsum) && (!s->status)) + *sigsum = GPGME_SIGSUM_GREEN; + } } } gpgme_data_release(data_text);