keyfork-shard: display error message on duplicate key fingerprints found
This commit is contained in:
parent
23db50956f
commit
e0687434ef
|
@ -205,11 +205,20 @@ impl<P: PromptHandler> OpenPGP<P> {
|
||||||
pub fn discover_certs(path: impl AsRef<Path>) -> Result<Vec<Cert>> {
|
pub fn discover_certs(path: impl AsRef<Path>) -> Result<Vec<Cert>> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
|
||||||
|
let mut pubkeys = std::collections::HashSet::new();
|
||||||
let mut certs = HashMap::new();
|
let mut certs = HashMap::new();
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
for maybe_cert in CertParser::from_file(path).map_err(Error::Sequoia)? {
|
for maybe_cert in CertParser::from_file(path).map_err(Error::Sequoia)? {
|
||||||
let cert = maybe_cert.map_err(Error::Sequoia)?;
|
let cert = maybe_cert.map_err(Error::Sequoia)?;
|
||||||
certs.insert(cert.fingerprint(), cert);
|
let certfp = cert.fingerprint();
|
||||||
|
for key in cert.keys() {
|
||||||
|
let fp = key.fingerprint();
|
||||||
|
if pubkeys.contains(&fp) {
|
||||||
|
eprintln!("Received duplicate key: {fp} in public key: {certfp}");
|
||||||
|
}
|
||||||
|
pubkeys.insert(fp);
|
||||||
|
}
|
||||||
|
certs.insert(certfp, cert);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for entry in path
|
for entry in path
|
||||||
|
@ -219,7 +228,15 @@ impl<P: PromptHandler> OpenPGP<P> {
|
||||||
.filter(|p| p.path().is_file())
|
.filter(|p| p.path().is_file())
|
||||||
{
|
{
|
||||||
let cert = Cert::from_file(entry.path()).map_err(Error::Sequoia)?;
|
let cert = Cert::from_file(entry.path()).map_err(Error::Sequoia)?;
|
||||||
certs.insert(cert.fingerprint(), cert);
|
let certfp = cert.fingerprint();
|
||||||
|
for key in cert.keys() {
|
||||||
|
let fp = key.fingerprint();
|
||||||
|
if pubkeys.contains(&fp) {
|
||||||
|
eprintln!("Received duplicate key: {fp} in public key: {certfp}");
|
||||||
|
}
|
||||||
|
pubkeys.insert(fp);
|
||||||
|
}
|
||||||
|
certs.insert(certfp, cert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(certs.into_values().collect())
|
Ok(certs.into_values().collect())
|
||||||
|
|
Loading…
Reference in New Issue