diff --git a/README.md b/README.md index f41a236..1227ad3 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,15 @@ cargo install age-plugin-yubikey Help from new packagers is very welcome. +### Linux, BSD, etc. + +On non-Windows, non-macOS systems, you need to ensure that the `pcscd` service +is installed and running. On Debian or Ubuntu, you can do this with: + +``` +$ sudo apt-get install pcscd +``` + ### Windows Subsystem for Linux (WSL) WSL does not currently provide native support for USB devices. However, Windows diff --git a/i18n/en-US/age_plugin_yubikey.ftl b/i18n/en-US/age_plugin_yubikey.ftl index a680bef..6d38c7c 100644 --- a/i18n/en-US/age_plugin_yubikey.ftl +++ b/i18n/en-US/age_plugin_yubikey.ftl @@ -12,6 +12,7 @@ -yubikey = YubiKey -yubikeys = YubiKeys -age-plugin-yubikey = age-plugin-yubikey +-pcscd = pcscd ## CLI commands and flags @@ -185,6 +186,22 @@ err-slot-has-no-identity = Slot {$slot} does not contain an {-age} identity or c err-slot-is-not-empty = Slot {$slot} is not empty. Use {-flag-force} to overwrite the slot. err-timed-out = Timed out while waiting for a {-yubikey} to be inserted. err-use-list-for-single = Use {-cmd-list} to print the recipient for a single slot. + +err-yk-no-service-macos = The Crypto Token Kit service is not running. +rec-yk-no-service-macos = + You may need to restart it. See this Stack Exchange answer for more help: + {" "}{$url} + +err-yk-no-service-pcscd = {-pcscd} is not running. +rec-yk-no-service-pcscd = + If you are on Debian or Ubuntu, you can install it with: + {" "}{$apt} + +err-yk-no-service-win = The Smart Cards for Windows service is not running. +rec-yk-no-service-win = + See this troubleshooting guide for more help: + {" "}{$url} + err-yk-not-found = Please insert the {-yubikey} you want to set up err-yk-wrong-pin = Invalid PIN ({$tries} tries remaining before it is blocked) err-yk-general = Error while communicating with {-yubikey}: {$err} diff --git a/src/error.rs b/src/error.rs index 0bc4719..d2033f2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -141,6 +141,35 @@ impl fmt::Debug for Error { Error::UseListForSingleSlot => wlnfl!(f, "err-use-list-for-single")?, Error::YubiKey(e) => match e { yubikey::Error::NotFound => wlnfl!(f, "err-yk-not-found")?, + yubikey::Error::PcscError { + inner: Some(pcsc::Error::NoService), + } => { + if cfg!(windows) { + wlnfl!(f, "err-yk-no-service-win")?; + let url = "https://learn.microsoft.com/en-us/windows/security/identity-protection/smart-cards/smart-card-debugging-information#smart-card-service"; + writeln!( + f, + "{}", + fl!(crate::LANGUAGE_LOADER, "rec-yk-no-service-win", url = url), + )?; + } else if cfg!(target_os = "macos") { + wlnfl!(f, "err-yk-no-service-macos")?; + let url = "https://apple.stackexchange.com/a/438198"; + writeln!( + f, + "{}", + fl!(crate::LANGUAGE_LOADER, "rec-yk-no-service-macos", url = url), + )?; + } else { + wlnfl!(f, "err-yk-no-service-pcscd")?; + let apt = "sudo apt-get install pcscd"; + writeln!( + f, + "{}", + fl!(crate::LANGUAGE_LOADER, "rec-yk-no-service-pcscd", apt = apt), + )?; + } + } yubikey::Error::WrongPin { tries } => writeln!( f, "{}",