Skip to content

Commit 682be6d

Browse files
committed
update caa-check
1 parent 85f0039 commit 682be6d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

server/lib/classes/letsencrypt.inc.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ public function request_certificates($data, $server_type = 'apache') {
373373
if((isset($web_config['skip_le_check']) && $web_config['skip_le_check'] == 'y') || (isset($server_config['migration_mode']) && $server_config['migration_mode'] == 'y')) {
374374
$le_domains[] = $temp_domain;
375375
} else {
376+
$le_hash_check = trim(@file_get_contents('http://' . $temp_domain . '/.well-known/acme-challenge/' . $le_rnd_file));
377+
if($le_hash_check == $le_rnd_hash) {
378+
$le_domains[] = $temp_domain;
379+
$app->log("Verified domain " . $temp_domain . " should be reachable for letsencrypt.", LOGLEVEL_DEBUG);
380+
} else {
381+
$app->log("Could not verify domain " . $temp_domain . ", so excluding it from letsencrypt request.", LOGLEVEL_WARN);
382+
}
383+
}
384+
}
385+
if(!empty($le_domains)) {
386+
foreach($le_domains as $idx=>$temp_domain) {
376387
//check caa-record
377388
$caa_check = false;
378389
$caa_domain = $temp_domain;
@@ -393,20 +404,13 @@ public function request_certificates($data, $server_type = 'apache') {
393404
$caa_check = true;
394405
}
395406

396-
if($caa_check === true) {
397-
$le_hash_check = trim(@file_get_contents('http://' . $temp_domain . '/.well-known/acme-challenge/' . $le_rnd_file));
398-
if($le_hash_check == $le_rnd_hash) {
399-
$le_domains[] = $temp_domain;
400-
$app->log("Verified domain " . $temp_domain . " should be reachable for letsencrypt.", LOGLEVEL_DEBUG);
401-
} else {
402-
$app->log("Could not verify domain " . $temp_domain . ", so excluding it from letsencrypt request.", LOGLEVEL_WARN);
403-
}
404-
} else {
407+
if($caa_check === false) {
405408
$app->log("Incomplete CAA-Records for " . $temp_domain . ", so excluding it from letsencrypt request.", LOGLEVEL_WARN);
409+
unset($le_domains[$idx]);
406410
}
407-
408411
}
409412
}
413+
410414
$temp_domains = $le_domains;
411415
unset($le_domains);
412416
@unlink('/usr/local/ispconfig/interface/acme/.well-known/acme-challenge/' . $le_rnd_file);

0 commit comments

Comments
 (0)