Skip to content

Commit

Permalink
Print cert loaded from disk
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonbaeten committed Feb 15, 2024
1 parent 59d6a94 commit a68d318
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/src/smtp/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn load_certs<'a>() -> Option<Vec<CertificateDer<'a>>> {
if certs.is_empty() {
None
} else {
info!("Loaded certificate {CERT_PATH}");
info!("Certificate loaded from disk:\n{}", String::from_utf8_lossy(&pem_bytes));

Some(certs)
}
Expand Down Expand Up @@ -56,9 +56,11 @@ pub(super) async fn create_tls_acceptor(name: &str) -> Result<TlsAcceptor> {
let full_cert = Certificate::from_params(cert_params)?;
let cert_pem = full_cert.serialize_pem()?;

fs::write(CERT_PATH, cert_pem).await?;
fs::write(CERT_PATH, &cert_pem).await?;
fs::write(KEY_PATH, full_cert.serialize_private_key_pem()).await?;

info!("Certificate generated:\n{cert_pem}");

let cert = CertificateDer::from(full_cert.serialize_der()?);
let key = PrivatePkcs8KeyDer::from(full_cert.serialize_private_key_der());

Expand Down

0 comments on commit a68d318

Please sign in to comment.