Skip to content

Commit bdbbb8b

Browse files
author
Thom
committed
Add check for zone existence when using DNS-01 verification (#4202)
1 parent fbaeb88 commit bdbbb8b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

server/lib/classes/letsencrypt.inc.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,21 @@ public function request_certificates($data, $server_type = 'apache') {
428428
} else {
429429
$app->log("Could not verify domain " . $temp_domain . ", so excluding it from letsencrypt request.", LOGLEVEL_WARN);
430430
}
431-
} else {
432-
// TODO BEFORE MERGING: strip subdomains from $temp_domain as $root_temp_domain
433-
if($app->dbmaster->queryOneRecord("SELECT * FROM dns_soa WHERE origin = ? AND active = 'y'", $root_temp_domain . ".") != null) {
431+
} else { // DNS-01 verification
432+
$temp_domain_parts = preg_split("/[.]/", $temp_domain);
433+
foreach ($temp_domain_parts as $temp_domain_part) {
434+
if (isset($temp_domain_parts['1'])) {
435+
$queryDomains[] = preg_replace("/.*" . $temp_domain_parts['0'] . "\." . "/", "", $temp_domain);
436+
array_shift($temp_domain_parts);
437+
print_r($temp_domain_parts);
438+
}
439+
}
440+
$queryOr = "origin = " . $temp_domain . ".";
441+
foreach ($queryDomains as $domain) {
442+
$queryOr .= " OR origin = " . $domain . ".";
443+
}
444+
445+
if($app->dbmaster->queryOneRecord("SELECT * FROM dns_soa WHERE active = y AND ?", $queryOr) != null) {
434446
$le_domains[] = $temp_domain;
435447
$app->log("Verified domain " . $temp_domain . " has a DNS zone in this setup for the acme (Let's Encrypt) challenge.", LOGLEVEL_DEBUG);
436448
} else {

0 commit comments

Comments
 (0)