added isDomainReal function to test beforehand if the domain has an A or AAAA record

This commit is contained in:
Nicolas Roman 2019-07-30 17:03:47 +02:00
parent ea352a045a
commit b60bd7a115
2 changed files with 24 additions and 0 deletions

View File

@ -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)) {

View File

@ -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