mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-23 21:51:06 +01:00
let's encrypt - wip
This commit is contained in:
parent
e1ee3a1c32
commit
e976758d92
@ -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(())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user