1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 00:01:11 +01:00

let's encrypt - wip

This commit is contained in:
jwdeitch 2019-08-07 07:55:09 -04:00
parent e1ee3a1c32
commit e976758d92

View File

@ -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(())
}
}