use lers::{solver::dns::CloudflareDns01Solver, Directory, LETS_ENCRYPT_STAGING_URL};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let solver = CloudflareDns01Solver::from_env()?.build()?;
let directory = Directory::builder(LETS_ENCRYPT_STAGING_URL)
.dns01_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);
Ok(())
}