Deduplicate subkey arguments when revoking subkeys.

- Fixes #348.
This commit is contained in:
Justus Winter 2024-10-02 12:10:59 +02:00
parent a2440d7cf0
commit 0710d4d2c7
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386

View File

@ -1,3 +1,5 @@
use std::collections::BTreeSet;
use anyhow::Context;
use chrono::DateTime;
@ -135,6 +137,7 @@ impl SubkeyRevocation {
= get_secret_signer(sq, &cert, revoker.as_ref())?;
let mut revocations = Vec::new();
let mut revoked = BTreeSet::new();
for keyhandle in keyhandles {
let keys = valid_cert.keys().subkeys()
.key_handle(keyhandle.clone())
@ -143,6 +146,13 @@ impl SubkeyRevocation {
if keys.len() == 1 {
let subkey = keys[0].clone();
// Did we already revoke it?
if revoked.contains(&subkey.fingerprint()) {
continue;
}
revoked.insert(subkey.fingerprint());
let mut rev = SubkeyRevocationBuilder::new()
.set_reason_for_revocation(reason, message.as_bytes())?;
rev = rev.set_signature_creation_time(sq.time)?;