From b60bd7a115d6082441f983b39f3487459dcbc12c Mon Sep 17 00:00:00 2001 From: Nicolas Roman Date: Tue, 30 Jul 2019 17:03:47 +0200 Subject: [PATCH] added isDomainReal function to test beforehand if the domain has an A or AAAA record --- inc/webadmin-letsencrypt.php | 10 ++++++++++ lib/letsencrypt.php | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/inc/webadmin-letsencrypt.php b/inc/webadmin-letsencrypt.php index 5b46c4a..47ca4e5 100644 --- a/inc/webadmin-letsencrypt.php +++ b/inc/webadmin-letsencrypt.php @@ -134,6 +134,16 @@ if (isset($_POST['submit'])) { // Check existing SSL certificate $domainsIncluded = array(); foreach ($_SESSION['letsencrypt-domains'] as $domain) { + + $isDomainReal = $letsencrypt->isDomainReal($domain); + + if ($isDomainReal === false) { + $errorMessage = "Erreur : le domaine " . $domain . " n'existe pas. Veuillez vérifier les enregistrements DNS."; + + array_push($messages, ["type" => "error", "content" => $errorMessage]); + break 2; + } + $existingSSLCertificate = $letsencrypt->getCertificate($domain); // if no certificate is present (false returned) for this domain, go to the next domain if (is_bool($existingSSLCertificate)) { diff --git a/lib/letsencrypt.php b/lib/letsencrypt.php index 8c0d2d4..deb427e 100644 --- a/lib/letsencrypt.php +++ b/lib/letsencrypt.php @@ -27,6 +27,20 @@ class LetsEncrypt sudoexec($cmd, $data_output, $exec_return); } + /** + * verify if the domain exists + * @param string $domain + * @return boolean + */ + public function isDomainReal($domain) + { + if (checkdnsrr($domain, 'A') || checkdnsrr($domain, 'AAAA')) { + return true; + } + + return false; + } + /** * generate a CSR * @param string $vhost