Move Certificate and PrivateKey into their own tls module

This commit is contained in:
Brian Picciano 2023-07-27 14:29:04 +02:00
parent 7a9ae81376
commit 4c1f843048
7 changed files with 13 additions and 12 deletions

View File

@ -5,6 +5,7 @@ pub mod manager;
mod name; mod name;
mod settings; mod settings;
pub mod store; pub mod store;
mod tls;
pub use config::*; pub use config::*;
pub use name::*; pub use name::*;

View File

@ -1,8 +1,2 @@
pub mod manager; pub mod manager;
pub mod store; pub mod store;
mod private_key;
pub use self::private_key::PrivateKey;
mod certificate;
pub use self::certificate::Certificate;

View File

@ -1,6 +1,7 @@
use std::{sync, time}; use std::{sync, time};
use crate::domain::acme::{self, Certificate, PrivateKey}; use crate::domain::acme;
use crate::domain::tls::{Certificate, PrivateKey};
use crate::error::unexpected::{self, Intoable, Mappable}; use crate::error::unexpected::{self, Intoable, Mappable};
use crate::{domain, token, util}; use crate::{domain, token, util};
@ -80,7 +81,7 @@ impl ManagerImpl {
.await .await
.or_unexpected_while("building account")?; .or_unexpected_while("building account")?;
let account_key: acme::PrivateKey = account let account_key: PrivateKey = account
.private_key() .private_key()
.as_ref() .as_ref()
.try_into() .try_into()
@ -242,7 +243,7 @@ impl Manager for ManagerImpl {
} }
// Generate an RSA private key for the certificate. // Generate an RSA private key for the certificate.
let pkey = acme::PrivateKey::new(); let pkey = PrivateKey::new();
let acme2_pkey = (&pkey) let acme2_pkey = (&pkey)
.try_into() .try_into()
@ -287,8 +288,8 @@ impl Manager for ManagerImpl {
"expected the order to return a certificate", "expected the order to return a certificate",
))? ))?
.into_iter() .into_iter()
.map(|cert| acme::Certificate::try_from(cert.as_ref())) .map(|cert| Certificate::try_from(cert.as_ref()))
.try_collect::<Vec<acme::Certificate>>() .try_collect::<Vec<Certificate>>()
.or_unexpected_while("parsing certificate")?; .or_unexpected_while("parsing certificate")?;
if cert.len() <= 1 { if cert.len() <= 1 {

View File

@ -2,7 +2,7 @@ use std::io::{Read, Write};
use std::str::FromStr; use std::str::FromStr;
use std::{fs, path}; use std::{fs, path};
use crate::domain::acme::{Certificate, PrivateKey}; use crate::domain::tls::{Certificate, PrivateKey};
use crate::error::unexpected::{self, Mappable}; use crate::error::unexpected::{self, Mappable};
use crate::util; use crate::util;

5
src/domain/tls.rs Normal file
View File

@ -0,0 +1,5 @@
mod private_key;
pub use self::private_key::PrivateKey;
mod certificate;
pub use self::certificate::Certificate;