mirror of https://github.com/breard-r/acmed.git
Browse Source
Move the account key type and signing algorithm
Move the account key type and signing algorithm
Those options are tied with the account and should therefore be defined in the associated section, not in the endpoint section.pull/39/head
Rodolphe Breard
4 years ago
8 changed files with 99 additions and 66 deletions
-
35acmed/src/account.rs
-
26acmed/src/acme_proto/account.rs
-
2acmed/src/certificate.rs
-
29acmed/src/config.rs
-
20acmed/src/endpoint.rs
-
1acmed/src/main.rs
-
2acmed/src/main_event_loop.rs
-
50man/en/acmed.toml.5
@ -0,0 +1,35 @@ |
|||
use acme_common::crypto::{JwsSignatureAlgorithm, KeyType};
|
|||
use acme_common::error::Error;
|
|||
use std::str::FromStr;
|
|||
|
|||
#[derive(Clone, Debug)]
|
|||
pub struct Account {
|
|||
pub name: String,
|
|||
pub email: String,
|
|||
pub key_type: KeyType,
|
|||
pub signature_algorithm: JwsSignatureAlgorithm,
|
|||
}
|
|||
|
|||
impl Account {
|
|||
pub fn new(
|
|||
name: &str,
|
|||
email: &str,
|
|||
key_type: &Option<String>,
|
|||
signature_algorithm: &Option<String>,
|
|||
) -> Result<Self, Error> {
|
|||
let key_type = match key_type {
|
|||
Some(kt) => KeyType::from_str(&kt)?,
|
|||
None => crate::DEFAULT_ACCOUNT_KEY_TYPE,
|
|||
};
|
|||
let signature_algorithm = match signature_algorithm {
|
|||
Some(sa) => JwsSignatureAlgorithm::from_str(&sa)?,
|
|||
None => key_type.get_default_signature_alg(),
|
|||
};
|
|||
Ok(crate::account::Account {
|
|||
name: name.to_string(),
|
|||
email: email.to_string(),
|
|||
key_type,
|
|||
signature_algorithm,
|
|||
})
|
|||
}
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue