diff --git a/lib/src/gpg_signing.rs b/lib/src/gpg_signing.rs index 2120ec569b..23603faed3 100644 --- a/lib/src/gpg_signing.rs +++ b/lib/src/gpg_signing.rs @@ -26,6 +26,7 @@ use std::str; use thiserror::Error; use crate::settings::ConfigResultExt as _; +use crate::settings::UserSettings; use crate::signing::SigStatus; use crate::signing::SignError; use crate::signing::SigningBackend; @@ -144,12 +145,14 @@ impl GpgBackend { self } - pub fn from_config(config: &config::Config) -> Result { - let program = config + pub fn from_settings(settings: &UserSettings) -> Result { + let program = settings + .config() .get_string("signing.backends.gpg.program") .optional()? .unwrap_or_else(|| "gpg".into()); - let allow_expired_keys = config + let allow_expired_keys = settings + .config() .get_bool("signing.backends.gpg.allow-expired-keys") .optional()? .unwrap_or(false); diff --git a/lib/src/signing.rs b/lib/src/signing.rs index 16dfb079c4..7a50cc5edd 100644 --- a/lib/src/signing.rs +++ b/lib/src/signing.rs @@ -162,12 +162,8 @@ impl Signer { /// chooses one of them to be used for signing depending on the config. pub fn from_settings(settings: &UserSettings) -> Result { let mut backends: Vec> = vec![ - Box::new( - GpgBackend::from_config(settings.config()).map_err(SignInitError::BackendConfig)?, - ), - Box::new( - SshBackend::from_config(settings.config()).map_err(SignInitError::BackendConfig)?, - ), + Box::new(GpgBackend::from_settings(settings).map_err(SignInitError::BackendConfig)?), + Box::new(SshBackend::from_settings(settings).map_err(SignInitError::BackendConfig)?), // Box::new(X509Backend::from_settings(settings).map_err(..)?), ]; diff --git a/lib/src/ssh_signing.rs b/lib/src/ssh_signing.rs index f858c3fb3b..fad1cda599 100644 --- a/lib/src/ssh_signing.rs +++ b/lib/src/ssh_signing.rs @@ -27,6 +27,7 @@ use either::Either; use thiserror::Error; use crate::settings::ConfigResultExt as _; +use crate::settings::UserSettings; use crate::signing::SigStatus; use crate::signing::SignError; use crate::signing::SigningBackend; @@ -117,12 +118,14 @@ impl SshBackend { } } - pub fn from_config(config: &config::Config) -> Result { - let program = config + pub fn from_settings(settings: &UserSettings) -> Result { + let program = settings + .config() .get_string("signing.backends.ssh.program") .optional()? .unwrap_or_else(|| "ssh-keygen".into()); - let allowed_signers = config + let allowed_signers = settings + .config() .get_string("signing.backends.ssh.allowed-signers") .optional()?; Ok(Self::new(program.into(), allowed_signers.map(|v| v.into())))