use lers::{solver::Http01Solver, Directory, LETS_ENCRYPT_STAGING_URL};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let address = "127.0.0.1:8080".parse()?;
let solver = Http01Solver::new();
let handle = solver.start(&address)?;
let directory = Directory::builder(LETS_ENCRYPT_STAGING_URL)
.http01_solver(Box::new(solver))
.build()
.await?;
let account = directory
.account()
.terms_of_service_agreed(true)
.contacts(vec!["mailto:hello@example.com".into()])
.create_if_not_exists()
.await?;
let certificate = account
.certificate()
.add_domain("example.com")
.obtain()
.await?;
assert!(certificate.x509_chain().len() > 1);
handle.stop().await?;
Ok(())
}