Repository: tweedegolf/mailcrab (language: rust)

Issue:
Certificate not printed
The README states:

> You can enable TLS and authentication by setting the environment variable ENABLE_TLS_AUTH=true. MailCrab will generate a key-pair and print the self-signed certificate.

With the latest version, though, the certificate is no longer printed. All I see in the logs is this:

```
2024-02-08T08:14:04.442398Z  INFO mailcrab_backend::smtp::tls: Generating self-signed certificate...
2024-02-08T08:14:04.443203Z  INFO mailcrab_backend::smtp::tls: TLS configuration loaded
```

It would be great to get this behaviour back as it made standing MailCrab up for quick tests much simpler.


Discussion / hints:

Fix patch:
diff --git a/backend/src/smtp/tls.rs b/backend/src/smtp/tls.rs
index 0a755c2..6ea4f9b 100644
--- a/backend/src/smtp/tls.rs
+++ b/backend/src/smtp/tls.rs
@@ -25,7 +25,10 @@ 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)
     }
@@ -56,9 +59,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());
 


Test patch: