Skip to content

Commit

Permalink
use dns check
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Feb 8, 2023
1 parent 03623d3 commit 5aa187f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions server/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ pub async fn cert_init_server(config: &crate::config::Config) -> AtomicServerRes
}

async fn request_cert(config: &crate::config::Config) -> AtomicServerResult<()> {
let use_wildcard = false;

fs::create_dir_all(PathBuf::from(&config.https_path))?;

// Create a new account. This will generate a fresh ECDSA key for you.
// Alternatively, restore an account from serialized credentials by
// using `Account::from_credentials()`.
Expand All @@ -176,7 +180,7 @@ async fn request_cert(config: &crate::config::Config) -> AtomicServerResult<()>

let account = instant_acme::Account::create(
&instant_acme::NewAccount {
contact: &[&email],
contact: &[&format!("mailto:{}", email)],
terms_of_service_agreed: true,
only_return_existing: false,
},
Expand All @@ -189,7 +193,11 @@ async fn request_cert(config: &crate::config::Config) -> AtomicServerResult<()>
// Note that this only needs an `&Account`, so the library will let you
// process multiple orders in parallel for a single account.

let identifier = instant_acme::Identifier::Dns(config.opts.domain.clone());
let mut domain = config.opts.domain.clone();
if use_wildcard {
domain = format!("*.{}", domain);
}
let identifier = instant_acme::Identifier::Dns(domain);
let (mut order, state) = account
.new_order(&instant_acme::NewOrder {
identifiers: &[identifier],
Expand All @@ -214,8 +222,8 @@ async fn request_cert(config: &crate::config::Config) -> AtomicServerResult<()>
let challenge = authz
.challenges
.iter()
.find(|c| c.r#type == instant_acme::ChallengeType::Http01)
.ok_or("no Http01 challenge found")?;
.find(|c| c.r#type == instant_acme::ChallengeType::Dns01)
.ok_or("no Dns01 challenge found")?;

let instant_acme::Identifier::Dns(identifier) = &authz.identifier;

Expand Down

0 comments on commit 5aa187f

Please sign in to comment.