mirror of
https://github.com/fafhrd91/actix-net
synced 2025-02-17 14:43:31 +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> {
|
struct CertificateRequest<'a> {
|
||||||
domains: &'a [&'a str]
|
domain: &'a str,
|
||||||
|
email: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CertificateRequest<'a> {
|
impl<'a> CertificateRequest<'a> {
|
||||||
fn new(domains: &'a [&'a str]) -> Self {
|
fn new(email: &'a str, domain: &'a str) -> Self {
|
||||||
return CertificateRequest { domains };
|
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…
x
Reference in New Issue
Block a user