diff options
author | Julian Gilbey <julian-git@d-and-j.net> | 2019-04-18 16:30:38 +0100 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2019-04-21 18:32:25 -0700 |
commit | 9351dd0195c71de6cf9b2beb51e9be4c5d2ea9ea (patch) | |
tree | 19c7592f74e97414b5f29ae249be98ca3eb8472c /crypt-gpgme.c | |
parent | 9da6bde1feafbe886c295027b959be47b4ad55b0 (diff) |
Handle the same secret key appearing in multiple public keyrings
Allow for S/MIME keys and the possibility of missing subkeys
Diffstat (limited to 'crypt-gpgme.c')
-rw-r--r-- | crypt-gpgme.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 3a1ed8a5..696daa62 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -940,6 +940,7 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime) gpgme_error_t err; gpgme_ctx_t listctx; gpgme_key_t key, key2; + char *fpr, *fpr2; if (for_smime) signid = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey; @@ -960,15 +961,25 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime) signid, gpgme_strerror (err)); return -1; } - err = gpgme_op_keylist_next (listctx, &key2); - if (!err) + fpr = "fpr1"; + if (key->subkeys) + fpr = key->subkeys->fpr ? key->subkeys->fpr : key->subkeys->keyid; + while (! gpgme_op_keylist_next (listctx, &key2)) { - gpgme_key_unref (key); - gpgme_key_unref (key2); - gpgme_release (listctx); - mutt_error (_("ambiguous specification of secret key `%s'\n"), - signid); - return -1; + fpr2 = "fpr2"; + if (key2->subkeys) + fpr2 = key2->subkeys->fpr ? key2->subkeys->fpr : key2->subkeys->keyid; + if (mutt_strcmp(fpr, fpr2)) + { + gpgme_key_unref (key); + gpgme_key_unref (key2); + gpgme_release (listctx); + mutt_error (_("ambiguous specification of secret key `%s'\n"), + signid); + return -1; + } else { + gpgme_key_unref (key2); + } } gpgme_op_keylist_end (listctx); gpgme_release (listctx); |