list: Ignore PIV devices we can't read from
This commit is contained in:
+14
-1
@@ -1,5 +1,6 @@
|
|||||||
use age_plugin::run_state_machine;
|
use age_plugin::run_state_machine;
|
||||||
use gumdrop::Options;
|
use gumdrop::Options;
|
||||||
|
use log::warn;
|
||||||
use yubikey_piv::{
|
use yubikey_piv::{
|
||||||
certificate::PublicKeyInfo,
|
certificate::PublicKeyInfo,
|
||||||
key::{RetiredSlotId, SlotId},
|
key::{RetiredSlotId, SlotId},
|
||||||
@@ -142,7 +143,19 @@ fn list(all: bool) -> Result<(), Error> {
|
|||||||
let mut readers = Readers::open()?;
|
let mut readers = Readers::open()?;
|
||||||
|
|
||||||
for reader in readers.iter()? {
|
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)? {
|
for key in Key::list(&mut yubikey)? {
|
||||||
// We only use the retired slots.
|
// We only use the retired slots.
|
||||||
|
|||||||
Reference in New Issue
Block a user