diff --git a/src/main.rs b/src/main.rs index 270d53b..fa128c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use age_plugin::run_state_machine; use gumdrop::Options; +use log::warn; use yubikey_piv::{ certificate::PublicKeyInfo, key::{RetiredSlotId, SlotId}, @@ -142,7 +143,19 @@ fn list(all: bool) -> Result<(), Error> { let mut readers = Readers::open()?; for reader in readers.iter()? { - let mut yubikey = reader.open()?; + let mut yubikey = match reader.open() { + Ok(yk) => yk, + Err(e) => { + use std::error::Error; + let reason = if let Some(inner) = e.source() { + format!("{}: {}", e, inner) + } else { + e.to_string() + }; + warn!("Ignoring {}: {}", reader.name(), reason); + continue; + } + }; for key in Key::list(&mut yubikey)? { // We only use the retired slots.