From e976758d92a63ad902bff36d57c68d189b914f14 Mon Sep 17 00:00:00 2001
From: jwdeitch <jwdeitch@gmail.com>
Date: Wed, 7 Aug 2019 07:55:09 -0400
Subject: [PATCH] let's encrypt - wip

---
 actix-lets-encrypt/src/certificate_signer.rs | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/actix-lets-encrypt/src/certificate_signer.rs b/actix-lets-encrypt/src/certificate_signer.rs
index 2fb1592d..6852da28 100644
--- a/actix-lets-encrypt/src/certificate_signer.rs
+++ b/actix-lets-encrypt/src/certificate_signer.rs
@@ -1,12 +1,26 @@
+use acme_client::Directory;
+
 struct CertificateRequest<'a> {
-    domains: &'a [&'a str]
+    domain: &'a str,
+    email: &'a str,
 }
 
 impl<'a> CertificateRequest<'a> {
-    fn new(domains: &'a [&'a str]) -> Self {
-        return CertificateRequest { domains };
+    fn new(email: &'a str, domain: &'a str) -> Self {
+        return CertificateRequest { domain, email };
     }
 
+    fn sign(self: &self) -> Result<(), std::io::Error> {
+        let directory = Directory::lets_encrypt()?;
+        let account = directory.account_registration()
+            .email(self.email)
+            .register()?;
+        let authorization = account.authorization("example.com")?;
+        let http_challenge = authorization.get_http_challenge().ok_or("HTTP challenge not found")?;
+
+        http_challenge.save_key_authorization("/var/www")?;
 
 
+        Ok(())
+    }
 }
\ No newline at end of file