@@ -22,36 +22,36 @@ |
||
| 22 | 22 | try { |
| 23 | 23 | // Initiating the client instance. In this case using the staging server (argument 2) and outputting all status |
| 24 | 24 | // and debug information (argument 3). |
| 25 | - $client = new LEClient($email, true, $logger); |
|
| 25 | + $client = new LEClient($email, true, $logger); |
|
| 26 | 26 | // Initiating the order instance. The keys and certificate will be stored in /example.org/ (argument 1) and the |
| 27 | 27 | // domains in the array (argument 2) will be on the certificate. |
| 28 | - $order = $client->getOrCreateOrder($basename, $domains); |
|
| 28 | + $order = $client->getOrCreateOrder($basename, $domains); |
|
| 29 | 29 | // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations. |
| 30 | - if (!$order->allAuthorizationsValid()) { |
|
| 31 | - // Get the DNS challenges from the pending authorizations. |
|
| 32 | - $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS); |
|
| 33 | - // Walk the list of pending authorization DNS challenges. |
|
| 34 | - if (!empty($pending)) { |
|
| 35 | - foreach ($pending as $challenge) { |
|
| 36 | - // For the purpose of this example, a fictitious functions creates or updates the ACME challenge DNS |
|
| 37 | - // record for this domain. |
|
| 38 | - //setDNSRecord($challenge['identifier'], $challenge['DNSDigest']); |
|
| 39 | - printf( |
|
| 40 | - "DNS Challengage identifier = %s digest = %s\n", |
|
| 41 | - $challenge['identifier'], |
|
| 42 | - $challenge['DNSDigest'] |
|
| 43 | - ); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 30 | + if (!$order->allAuthorizationsValid()) { |
|
| 31 | + // Get the DNS challenges from the pending authorizations. |
|
| 32 | + $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS); |
|
| 33 | + // Walk the list of pending authorization DNS challenges. |
|
| 34 | + if (!empty($pending)) { |
|
| 35 | + foreach ($pending as $challenge) { |
|
| 36 | + // For the purpose of this example, a fictitious functions creates or updates the ACME challenge DNS |
|
| 37 | + // record for this domain. |
|
| 38 | + //setDNSRecord($challenge['identifier'], $challenge['DNSDigest']); |
|
| 39 | + printf( |
|
| 40 | + "DNS Challengage identifier = %s digest = %s\n", |
|
| 41 | + $challenge['identifier'], |
|
| 42 | + $challenge['DNSDigest'] |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | catch (\Exception $e) { |
| 49 | - echo $e->getMessage()."\n"; |
|
| 50 | - echo $e->getTraceAsString()."\n"; |
|
| 49 | + echo $e->getMessage()."\n"; |
|
| 50 | + echo $e->getTraceAsString()."\n"; |
|
| 51 | 51 | |
| 52 | - echo "\nDiagnostic logs\n"; |
|
| 53 | - $logger->dumpConsole(); |
|
| 54 | - exit; |
|
| 52 | + echo "\nDiagnostic logs\n"; |
|
| 53 | + $logger->dumpConsole(); |
|
| 54 | + exit; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | echo "\nDiagnostic logs\n"; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elphin\LEClient; |
| 3 | 3 | |
| 4 | -require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 4 | +require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 5 | 5 | |
| 6 | 6 | //Sets the maximum execution time to two minutes, to be sure. |
| 7 | 7 | ini_set('max_execution_time', 120); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | $email = ['[email protected]']; |
| 17 | 17 | $basename = 'le.dixo.net'; |
| 18 | -$domains=['le.dixo.net']; |
|
| 18 | +$domains = ['le.dixo.net']; |
|
| 19 | 19 | |
| 20 | 20 | $logger = new DiagnosticLogger; |
| 21 | 21 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | catch (\Exception $e) { |
| 49 | - echo $e->getMessage()."\n"; |
|
| 50 | - echo $e->getTraceAsString()."\n"; |
|
| 49 | + echo $e->getMessage() . "\n"; |
|
| 50 | + echo $e->getTraceAsString() . "\n"; |
|
| 51 | 51 | |
| 52 | 52 | echo "\nDiagnostic logs\n"; |
| 53 | 53 | $logger->dumpConsole(); |
@@ -44,8 +44,7 @@ |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | -} |
|
| 48 | -catch (\Exception $e) { |
|
| 47 | +} catch (\Exception $e) { |
|
| 49 | 48 | echo $e->getMessage()."\n"; |
| 50 | 49 | echo $e->getTraceAsString()."\n"; |
| 51 | 50 | |
@@ -49,8 +49,8 @@ |
||
| 49 | 49 | if($order->isFinalized()) $order->getCertificate(); |
| 50 | 50 | |
| 51 | 51 | //finally, here's how we revoke |
| 52 | - //echo "REVOKING...\n"; |
|
| 53 | - //$order->revokeCertificate(); |
|
| 52 | + //echo "REVOKING...\n"; |
|
| 53 | + //$order->revokeCertificate(); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elphin\LEClient; |
| 3 | 3 | |
| 4 | -require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 4 | +require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 5 | 5 | |
| 6 | 6 | //Sets the maximum execution time to two minutes, to be sure. |
| 7 | 7 | ini_set('max_execution_time', 120); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | $email = ['[email protected]']; |
| 17 | 17 | $basename = 'le.dixo.net'; |
| 18 | -$domains=['le.dixo.net']; |
|
| 18 | +$domains = ['le.dixo.net']; |
|
| 19 | 19 | |
| 20 | 20 | $logger = new DiagnosticLogger; |
| 21 | 21 | |
@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | // in the array (argument 2) will be on the certificate. |
| 27 | 27 | $order = $client->getOrCreateOrder($basename, $domains); |
| 28 | 28 | // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations. |
| 29 | -if(!$order->allAuthorizationsValid()) |
|
| 29 | +if (!$order->allAuthorizationsValid()) |
|
| 30 | 30 | { |
| 31 | 31 | // Get the DNS challenges from the pending authorizations. |
| 32 | 32 | $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS); |
| 33 | 33 | // Walk the list of pending authorization DNS challenges. |
| 34 | - if(!empty($pending)) |
|
| 34 | + if (!empty($pending)) |
|
| 35 | 35 | { |
| 36 | - foreach($pending as $challenge) |
|
| 36 | + foreach ($pending as $challenge) |
|
| 37 | 37 | { |
| 38 | 38 | // Let LetsEncrypt verify this challenge, which should have been fulfilled in exampleDNSStart.php. |
| 39 | 39 | $order->verifyPendingOrderAuthorization($challenge['identifier'], LEOrder::CHALLENGE_TYPE_DNS); |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | // Check once more whether all authorizations are valid before we can finalize the order. |
| 44 | -if($order->allAuthorizationsValid()) |
|
| 44 | +if ($order->allAuthorizationsValid()) |
|
| 45 | 45 | { |
| 46 | 46 | // Finalize the order first, if that is not yet done. |
| 47 | - if(!$order->isFinalized()) $order->finalizeOrder(); |
|
| 47 | + if (!$order->isFinalized()) $order->finalizeOrder(); |
|
| 48 | 48 | // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. |
| 49 | - if($order->isFinalized()) $order->getCertificate(); |
|
| 49 | + if ($order->isFinalized()) $order->getCertificate(); |
|
| 50 | 50 | |
| 51 | 51 | //finally, here's how we revoke |
| 52 | 52 | //echo "REVOKING...\n"; |
@@ -44,9 +44,13 @@ |
||
| 44 | 44 | if($order->allAuthorizationsValid()) |
| 45 | 45 | { |
| 46 | 46 | // Finalize the order first, if that is not yet done. |
| 47 | - if(!$order->isFinalized()) $order->finalizeOrder(); |
|
| 47 | + if(!$order->isFinalized()) { |
|
| 48 | + $order->finalizeOrder(); |
|
| 49 | + } |
|
| 48 | 50 | // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. |
| 49 | - if($order->isFinalized()) $order->getCertificate(); |
|
| 51 | + if($order->isFinalized()) { |
|
| 52 | + $order->getCertificate(); |
|
| 53 | + } |
|
| 50 | 54 | |
| 51 | 55 | //finally, here's how we revoke |
| 52 | 56 | //echo "REVOKING...\n"; |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | foreach($pending as $challenge) |
| 33 | 33 | { |
| 34 | 34 | // Define the folder in which to store the challenge. For the purpose of this example, a fictitious path is |
| 35 | - // set. |
|
| 35 | + // set. |
|
| 36 | 36 | $folder = '/path/to/' . $challenge['identifier'] . '/.well-known/acme-challenge/'; |
| 37 | 37 | // Check if that directory yet exists. If not, create it. |
| 38 | 38 | if(!file_exists($folder)) mkdir($folder, 0777, true); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elphin\LEClient; |
| 3 | 3 | |
| 4 | -require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 4 | +require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 5 | 5 | |
| 6 | 6 | //Sets the maximum execution time to two minutes, to be sure. |
| 7 | 7 | ini_set('max_execution_time', 120); |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | // domains in the array (argument 2) will be on the certificate. |
| 23 | 23 | $order = $client->getOrCreateOrder($basename, $domains); |
| 24 | 24 | // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations. |
| 25 | -if(!$order->allAuthorizationsValid()) |
|
| 25 | +if (!$order->allAuthorizationsValid()) |
|
| 26 | 26 | { |
| 27 | 27 | // Get the HTTP challenges from the pending authorizations. |
| 28 | 28 | $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_HTTP); |
| 29 | 29 | // Walk the list of pending authorization HTTP challenges. |
| 30 | - if(!empty($pending)) |
|
| 30 | + if (!empty($pending)) |
|
| 31 | 31 | { |
| 32 | - foreach($pending as $challenge) |
|
| 32 | + foreach ($pending as $challenge) |
|
| 33 | 33 | { |
| 34 | 34 | // Define the folder in which to store the challenge. For the purpose of this example, a fictitious path is |
| 35 | 35 | // set. |
| 36 | 36 | $folder = '/path/to/' . $challenge['identifier'] . '/.well-known/acme-challenge/'; |
| 37 | 37 | // Check if that directory yet exists. If not, create it. |
| 38 | - if(!file_exists($folder)) mkdir($folder, 0777, true); |
|
| 38 | + if (!file_exists($folder)) mkdir($folder, 0777, true); |
|
| 39 | 39 | // Store the challenge file for this domain. |
| 40 | 40 | file_put_contents($folder . $challenge['filename'], $challenge['content']); |
| 41 | 41 | // Let LetsEncrypt verify this challenge. |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | // Check once more whether all authorizations are valid before we can finalize the order. |
| 47 | -if($order->allAuthorizationsValid()) |
|
| 47 | +if ($order->allAuthorizationsValid()) |
|
| 48 | 48 | { |
| 49 | 49 | // Finalize the order first, if that is not yet done. |
| 50 | - if(!$order->isFinalized()) $order->finalizeOrder(); |
|
| 50 | + if (!$order->isFinalized()) $order->finalizeOrder(); |
|
| 51 | 51 | // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. |
| 52 | - if($order->isFinalized()) $order->getCertificate(); |
|
| 52 | + if ($order->isFinalized()) $order->getCertificate(); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | echo "\nDiagnostic logs\n"; |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | // set. |
| 36 | 36 | $folder = '/path/to/' . $challenge['identifier'] . '/.well-known/acme-challenge/'; |
| 37 | 37 | // Check if that directory yet exists. If not, create it. |
| 38 | - if(!file_exists($folder)) mkdir($folder, 0777, true); |
|
| 38 | + if(!file_exists($folder)) { |
|
| 39 | + mkdir($folder, 0777, true); |
|
| 40 | + } |
|
| 39 | 41 | // Store the challenge file for this domain. |
| 40 | 42 | file_put_contents($folder . $challenge['filename'], $challenge['content']); |
| 41 | 43 | // Let LetsEncrypt verify this challenge. |
@@ -47,10 +49,14 @@ discard block |
||
| 47 | 49 | if($order->allAuthorizationsValid()) |
| 48 | 50 | { |
| 49 | 51 | // Finalize the order first, if that is not yet done. |
| 50 | - if(!$order->isFinalized()) $order->finalizeOrder(); |
|
| 52 | + if(!$order->isFinalized()) { |
|
| 53 | + $order->finalizeOrder(); |
|
| 54 | + } |
|
| 51 | 55 | // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. |
| 52 | - if($order->isFinalized()) $order->getCertificate(); |
|
| 53 | -} |
|
| 56 | + if($order->isFinalized()) { |
|
| 57 | + $order->getCertificate(); |
|
| 58 | + } |
|
| 59 | + } |
|
| 54 | 60 | |
| 55 | 61 | echo "\nDiagnostic logs\n"; |
| 56 | 62 | $logger->dumpConsole(); |
| 57 | 63 | \ No newline at end of file |
@@ -13,88 +13,88 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class DiagnosticLogger extends AbstractLogger |
| 15 | 15 | { |
| 16 | - private $logs = []; |
|
| 17 | - |
|
| 18 | - public function log($level, $message, array $context = []) |
|
| 19 | - { |
|
| 20 | - $this->logs[] = [$level, $message, $context]; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function dumpConsole($useColours = true) |
|
| 24 | - { |
|
| 25 | - $colours = [ |
|
| 26 | - 'alert' => "\e[97m\e[41m", |
|
| 27 | - 'emergency' => "\e[97m\e[41m", |
|
| 28 | - 'critical' => "\e[97m\e[41m", |
|
| 29 | - 'error' => "\e[91m", |
|
| 30 | - 'warning' => "\e[93m", |
|
| 31 | - 'notice' => "\e[96m", |
|
| 32 | - 'info' => "\e[92m", |
|
| 33 | - 'debug' => "\e[2m", |
|
| 34 | - ]; |
|
| 35 | - |
|
| 36 | - $reset = $useColours ? "\e[0m" : ''; |
|
| 37 | - |
|
| 38 | - foreach ($this->logs as $log) { |
|
| 39 | - $col = $useColours ? $colours[$log[0]] : ''; |
|
| 40 | - echo $col . $log[0] . ': ' . $this->interpolateMessage($log[1], $log[2]) . $reset . "\n"; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function dumpHTML($echo = true) |
|
| 45 | - { |
|
| 46 | - $html = '<div class="liblynx-diagnostic-log">'; |
|
| 47 | - $html .= '<table class="table"><thead><tr><th>Level</th><th>Message</th></tr></thead><tbody>'; |
|
| 48 | - $html .= "\n"; |
|
| 49 | - |
|
| 50 | - foreach ($this->logs as $log) { |
|
| 51 | - $html .= '<tr class="level-' . $log[0] . '"><td>' . $log[0] . '</td><td>' . |
|
| 52 | - htmlentities($this->interpolateMessage($log[1], $log[2])) . |
|
| 53 | - "</td></tr>\n"; |
|
| 54 | - } |
|
| 55 | - $html .= "</tbody></table></div>\n"; |
|
| 56 | - |
|
| 57 | - if ($echo) { |
|
| 58 | - echo $html; //@codeCoverageIgnore |
|
| 59 | - } |
|
| 60 | - return $html; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Interpolates context values into the message placeholders. |
|
| 65 | - */ |
|
| 66 | - private function interpolateMessage($message, array $context = []) |
|
| 67 | - { |
|
| 68 | - // build a replacement array with braces around the context keys |
|
| 69 | - $replace = []; |
|
| 70 | - foreach ($context as $key => $val) { |
|
| 71 | - // check that the value can be casted to string |
|
| 72 | - if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
|
| 73 | - $replace['{' . $key . '}'] = $val; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // interpolate replacement values into the message and return |
|
| 78 | - return strtr($message, $replace); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - public function cleanLogs() |
|
| 83 | - { |
|
| 84 | - $logs = $this->logs; |
|
| 85 | - $this->logs = []; |
|
| 86 | - |
|
| 87 | - return $logs; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public function countLogs($level) |
|
| 91 | - { |
|
| 92 | - $count = 0; |
|
| 93 | - foreach ($this->logs as $log) { |
|
| 94 | - if ($log[0] == $level) { |
|
| 95 | - $count++; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - return $count; |
|
| 99 | - } |
|
| 16 | + private $logs = []; |
|
| 17 | + |
|
| 18 | + public function log($level, $message, array $context = []) |
|
| 19 | + { |
|
| 20 | + $this->logs[] = [$level, $message, $context]; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function dumpConsole($useColours = true) |
|
| 24 | + { |
|
| 25 | + $colours = [ |
|
| 26 | + 'alert' => "\e[97m\e[41m", |
|
| 27 | + 'emergency' => "\e[97m\e[41m", |
|
| 28 | + 'critical' => "\e[97m\e[41m", |
|
| 29 | + 'error' => "\e[91m", |
|
| 30 | + 'warning' => "\e[93m", |
|
| 31 | + 'notice' => "\e[96m", |
|
| 32 | + 'info' => "\e[92m", |
|
| 33 | + 'debug' => "\e[2m", |
|
| 34 | + ]; |
|
| 35 | + |
|
| 36 | + $reset = $useColours ? "\e[0m" : ''; |
|
| 37 | + |
|
| 38 | + foreach ($this->logs as $log) { |
|
| 39 | + $col = $useColours ? $colours[$log[0]] : ''; |
|
| 40 | + echo $col . $log[0] . ': ' . $this->interpolateMessage($log[1], $log[2]) . $reset . "\n"; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function dumpHTML($echo = true) |
|
| 45 | + { |
|
| 46 | + $html = '<div class="liblynx-diagnostic-log">'; |
|
| 47 | + $html .= '<table class="table"><thead><tr><th>Level</th><th>Message</th></tr></thead><tbody>'; |
|
| 48 | + $html .= "\n"; |
|
| 49 | + |
|
| 50 | + foreach ($this->logs as $log) { |
|
| 51 | + $html .= '<tr class="level-' . $log[0] . '"><td>' . $log[0] . '</td><td>' . |
|
| 52 | + htmlentities($this->interpolateMessage($log[1], $log[2])) . |
|
| 53 | + "</td></tr>\n"; |
|
| 54 | + } |
|
| 55 | + $html .= "</tbody></table></div>\n"; |
|
| 56 | + |
|
| 57 | + if ($echo) { |
|
| 58 | + echo $html; //@codeCoverageIgnore |
|
| 59 | + } |
|
| 60 | + return $html; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Interpolates context values into the message placeholders. |
|
| 65 | + */ |
|
| 66 | + private function interpolateMessage($message, array $context = []) |
|
| 67 | + { |
|
| 68 | + // build a replacement array with braces around the context keys |
|
| 69 | + $replace = []; |
|
| 70 | + foreach ($context as $key => $val) { |
|
| 71 | + // check that the value can be casted to string |
|
| 72 | + if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
|
| 73 | + $replace['{' . $key . '}'] = $val; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // interpolate replacement values into the message and return |
|
| 78 | + return strtr($message, $replace); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + public function cleanLogs() |
|
| 83 | + { |
|
| 84 | + $logs = $this->logs; |
|
| 85 | + $this->logs = []; |
|
| 86 | + |
|
| 87 | + return $logs; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public function countLogs($level) |
|
| 91 | + { |
|
| 92 | + $count = 0; |
|
| 93 | + foreach ($this->logs as $log) { |
|
| 94 | + if ($log[0] == $level) { |
|
| 95 | + $count++; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + return $count; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function __construct($dir = null) |
| 16 | 16 | { |
| 17 | - $this->dir = $dir ?? getcwd().DIRECTORY_SEPARATOR.'certificates'; |
|
| 17 | + $this->dir = $dir ?? getcwd() . DIRECTORY_SEPARATOR . 'certificates'; |
|
| 18 | 18 | |
| 19 | 19 | if (!is_dir($this->dir)) { |
| 20 | 20 | /** @scrutinizer ignore-unhandled */ @mkdir($this->dir); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | private function getDomainKey($domain, $suffix) |
| 61 | 61 | { |
| 62 | - return str_replace('*', 'wildcard', $domain).'.'.$suffix; |
|
| 62 | + return str_replace('*', 'wildcard', $domain) . '.' . $suffix; |
|
| 63 | 63 | } |
| 64 | 64 | /** |
| 65 | 65 | * @inheritdoc |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | private function getMetadataFilename($key) |
| 129 | 129 | { |
| 130 | - $key=str_replace('*', 'wildcard', $key); |
|
| 131 | - $file=$this->dir.DIRECTORY_SEPARATOR.$key; |
|
| 130 | + $key = str_replace('*', 'wildcard', $key); |
|
| 131 | + $file = $this->dir . DIRECTORY_SEPARATOR . $key; |
|
| 132 | 132 | return $file; |
| 133 | 133 | } |
| 134 | 134 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function getMetadata($key) |
| 138 | 138 | { |
| 139 | - $file=$this->getMetadataFilename($key); |
|
| 139 | + $file = $this->getMetadataFilename($key); |
|
| 140 | 140 | if (!file_exists($file)) { |
| 141 | 141 | return null; |
| 142 | 142 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function setMetadata($key, $value) |
| 150 | 150 | { |
| 151 | - $file=$this->getMetadataFilename($key); |
|
| 151 | + $file = $this->getMetadataFilename($key); |
|
| 152 | 152 | if (is_null($value)) { |
| 153 | 153 | //nothing to store, ensure file is removed |
| 154 | 154 | if (file_exists($file)) { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function hasMetadata($key) |
| 166 | 166 | { |
| 167 | - $file=$this->getMetadataFilename($key); |
|
| 167 | + $file = $this->getMetadataFilename($key); |
|
| 168 | 168 | return file_exists($file); |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -10,128 +10,128 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class FilesystemCertificateStorage implements CertificateStorageInterface |
| 12 | 12 | { |
| 13 | - private $dir; |
|
| 14 | - |
|
| 15 | - public function __construct($dir = null) |
|
| 16 | - { |
|
| 17 | - $this->dir = $dir ?? getcwd().DIRECTORY_SEPARATOR.'certificates'; |
|
| 18 | - |
|
| 19 | - if (!is_dir($this->dir)) { |
|
| 20 | - /** @scrutinizer ignore-unhandled */ @mkdir($this->dir); |
|
| 21 | - } |
|
| 22 | - if (!is_writable($this->dir)) { |
|
| 23 | - throw new RuntimeException("{$this->dir} is not writable"); |
|
| 24 | - } |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - private function getDomainKey($domain, $suffix) |
|
| 28 | - { |
|
| 29 | - return str_replace('*', 'wildcard', $domain).'.'.$suffix; |
|
| 30 | - } |
|
| 31 | - /** |
|
| 32 | - * @inheritdoc |
|
| 33 | - */ |
|
| 34 | - public function getCertificate($domain) |
|
| 35 | - { |
|
| 36 | - return $this->getMetadata($this->getDomainKey($domain, 'crt')); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @inheritdoc |
|
| 41 | - */ |
|
| 42 | - public function setCertificate($domain, $certificate) |
|
| 43 | - { |
|
| 44 | - $this->setMetadata($this->getDomainKey($domain, 'crt'), $certificate); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @inheritdoc |
|
| 49 | - */ |
|
| 50 | - public function getFullChainCertificate($domain) |
|
| 51 | - { |
|
| 52 | - return $this->getMetadata($this->getDomainKey($domain, 'fullchain.crt')); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @inheritdoc |
|
| 57 | - */ |
|
| 58 | - public function setFullChainCertificate($domain, $certificate) |
|
| 59 | - { |
|
| 60 | - $this->setMetadata($this->getDomainKey($domain, 'fullchain.crt'), $certificate); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @inheritdoc |
|
| 65 | - */ |
|
| 66 | - public function getPrivateKey($domain) |
|
| 67 | - { |
|
| 68 | - return $this->getMetadata($this->getDomainKey($domain, 'key')); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @inheritdoc |
|
| 73 | - */ |
|
| 74 | - public function setPrivateKey($domain, $key) |
|
| 75 | - { |
|
| 76 | - $this->setMetadata($this->getDomainKey($domain, 'key'), $key); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @inheritdoc |
|
| 81 | - */ |
|
| 82 | - public function getPublicKey($domain) |
|
| 83 | - { |
|
| 84 | - return $this->getMetadata($this->getDomainKey($domain, 'public')); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @inheritdoc |
|
| 89 | - */ |
|
| 90 | - public function setPublicKey($domain, $key) |
|
| 91 | - { |
|
| 92 | - $this->setMetadata($this->getDomainKey($domain, 'public'), $key); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - private function getMetadataFilename($key) |
|
| 96 | - { |
|
| 97 | - $key=str_replace('*', 'wildcard', $key); |
|
| 98 | - $file=$this->dir.DIRECTORY_SEPARATOR.$key; |
|
| 99 | - return $file; |
|
| 100 | - } |
|
| 101 | - /** |
|
| 102 | - * @inheritdoc |
|
| 103 | - */ |
|
| 104 | - public function getMetadata($key) |
|
| 105 | - { |
|
| 106 | - $file=$this->getMetadataFilename($key); |
|
| 107 | - if (!file_exists($file)) { |
|
| 108 | - return null; |
|
| 109 | - } |
|
| 110 | - return file_get_contents($file); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @inheritdoc |
|
| 115 | - */ |
|
| 116 | - public function setMetadata($key, $value) |
|
| 117 | - { |
|
| 118 | - $file=$this->getMetadataFilename($key); |
|
| 119 | - if (is_null($value)) { |
|
| 120 | - //nothing to store, ensure file is removed |
|
| 121 | - if (file_exists($file)) { |
|
| 122 | - unlink($file); |
|
| 123 | - } |
|
| 124 | - } else { |
|
| 125 | - file_put_contents($file, $value); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @inheritdoc |
|
| 131 | - */ |
|
| 132 | - public function hasMetadata($key) |
|
| 133 | - { |
|
| 134 | - $file=$this->getMetadataFilename($key); |
|
| 135 | - return file_exists($file); |
|
| 136 | - } |
|
| 13 | + private $dir; |
|
| 14 | + |
|
| 15 | + public function __construct($dir = null) |
|
| 16 | + { |
|
| 17 | + $this->dir = $dir ?? getcwd().DIRECTORY_SEPARATOR.'certificates'; |
|
| 18 | + |
|
| 19 | + if (!is_dir($this->dir)) { |
|
| 20 | + /** @scrutinizer ignore-unhandled */ @mkdir($this->dir); |
|
| 21 | + } |
|
| 22 | + if (!is_writable($this->dir)) { |
|
| 23 | + throw new RuntimeException("{$this->dir} is not writable"); |
|
| 24 | + } |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + private function getDomainKey($domain, $suffix) |
|
| 28 | + { |
|
| 29 | + return str_replace('*', 'wildcard', $domain).'.'.$suffix; |
|
| 30 | + } |
|
| 31 | + /** |
|
| 32 | + * @inheritdoc |
|
| 33 | + */ |
|
| 34 | + public function getCertificate($domain) |
|
| 35 | + { |
|
| 36 | + return $this->getMetadata($this->getDomainKey($domain, 'crt')); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @inheritdoc |
|
| 41 | + */ |
|
| 42 | + public function setCertificate($domain, $certificate) |
|
| 43 | + { |
|
| 44 | + $this->setMetadata($this->getDomainKey($domain, 'crt'), $certificate); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @inheritdoc |
|
| 49 | + */ |
|
| 50 | + public function getFullChainCertificate($domain) |
|
| 51 | + { |
|
| 52 | + return $this->getMetadata($this->getDomainKey($domain, 'fullchain.crt')); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @inheritdoc |
|
| 57 | + */ |
|
| 58 | + public function setFullChainCertificate($domain, $certificate) |
|
| 59 | + { |
|
| 60 | + $this->setMetadata($this->getDomainKey($domain, 'fullchain.crt'), $certificate); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @inheritdoc |
|
| 65 | + */ |
|
| 66 | + public function getPrivateKey($domain) |
|
| 67 | + { |
|
| 68 | + return $this->getMetadata($this->getDomainKey($domain, 'key')); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @inheritdoc |
|
| 73 | + */ |
|
| 74 | + public function setPrivateKey($domain, $key) |
|
| 75 | + { |
|
| 76 | + $this->setMetadata($this->getDomainKey($domain, 'key'), $key); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @inheritdoc |
|
| 81 | + */ |
|
| 82 | + public function getPublicKey($domain) |
|
| 83 | + { |
|
| 84 | + return $this->getMetadata($this->getDomainKey($domain, 'public')); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @inheritdoc |
|
| 89 | + */ |
|
| 90 | + public function setPublicKey($domain, $key) |
|
| 91 | + { |
|
| 92 | + $this->setMetadata($this->getDomainKey($domain, 'public'), $key); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + private function getMetadataFilename($key) |
|
| 96 | + { |
|
| 97 | + $key=str_replace('*', 'wildcard', $key); |
|
| 98 | + $file=$this->dir.DIRECTORY_SEPARATOR.$key; |
|
| 99 | + return $file; |
|
| 100 | + } |
|
| 101 | + /** |
|
| 102 | + * @inheritdoc |
|
| 103 | + */ |
|
| 104 | + public function getMetadata($key) |
|
| 105 | + { |
|
| 106 | + $file=$this->getMetadataFilename($key); |
|
| 107 | + if (!file_exists($file)) { |
|
| 108 | + return null; |
|
| 109 | + } |
|
| 110 | + return file_get_contents($file); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @inheritdoc |
|
| 115 | + */ |
|
| 116 | + public function setMetadata($key, $value) |
|
| 117 | + { |
|
| 118 | + $file=$this->getMetadataFilename($key); |
|
| 119 | + if (is_null($value)) { |
|
| 120 | + //nothing to store, ensure file is removed |
|
| 121 | + if (file_exists($file)) { |
|
| 122 | + unlink($file); |
|
| 123 | + } |
|
| 124 | + } else { |
|
| 125 | + file_put_contents($file, $value); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @inheritdoc |
|
| 131 | + */ |
|
| 132 | + public function hasMetadata($key) |
|
| 133 | + { |
|
| 134 | + $file=$this->getMetadataFilename($key); |
|
| 135 | + return file_exists($file); |
|
| 136 | + } |
|
| 137 | 137 | } |
@@ -39,93 +39,93 @@ |
||
| 39 | 39 | class DNSOverHTTPS implements DNSValidatorInterface |
| 40 | 40 | { |
| 41 | 41 | |
| 42 | - const DNS_GOOGLE = 'https://dns.google.com/resolve'; |
|
| 43 | - const DNS_MOZILLA = 'https://mozilla.cloudflare-dns.com/dns-query'; |
|
| 44 | - const DNS_CLOUDFLARE = 'https://cloudflare-dns.com/dns-query'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * What DNS-over-HTTPS service to use |
|
| 48 | - * |
|
| 49 | - * @var null|string |
|
| 50 | - */ |
|
| 51 | - private $baseURI; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Guzzle client handler |
|
| 55 | - * |
|
| 56 | - * @var Client object |
|
| 57 | - */ |
|
| 58 | - private $client; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * DNSOverHTTPS constructor. |
|
| 62 | - * @param string|null $baseURI |
|
| 63 | - */ |
|
| 64 | - public function __construct(string $baseURI = null) |
|
| 65 | - { |
|
| 66 | - //Default to Google, seems like a safe bet... |
|
| 67 | - if ($baseURI === null) { |
|
| 68 | - $this->baseURI = self::DNS_GOOGLE; |
|
| 69 | - } else { |
|
| 70 | - $this->baseURI = $baseURI; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - $this->client = new Client([ |
|
| 74 | - 'base_uri' => $this->baseURI |
|
| 75 | - ]); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function checkChallenge($domain, $requiredDigest) : bool |
|
| 79 | - { |
|
| 80 | - $hostname = '_acme-challenge.' . str_replace('*.', '', $domain); |
|
| 81 | - |
|
| 82 | - $records = $this->get($hostname, 'TXT'); |
|
| 83 | - if ($records->Status == 0) { |
|
| 84 | - foreach ($records->Answer as $record) { |
|
| 85 | - if ((rtrim($record->name, ".") == $hostname) && |
|
| 86 | - ($record->type == 16) && |
|
| 87 | - (trim($record->data, '"') == $requiredDigest)) { |
|
| 88 | - return true; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @param string $name |
|
| 98 | - * @param string $type per experimental spec this can be string OR int, we force string |
|
| 99 | - * @return \stdClass |
|
| 100 | - */ |
|
| 101 | - public function get(string $name, string $type) : \stdClass |
|
| 102 | - { |
|
| 103 | - $query = [ |
|
| 104 | - 'query' => [ |
|
| 105 | - 'name' => $name, |
|
| 106 | - 'type' => $type, |
|
| 107 | - 'edns_client_subnet' => '0.0.0.0/0', //disable geotagged dns results |
|
| 108 | - 'ct' => 'application/dns-json', //cloudflare requires this |
|
| 109 | - ], |
|
| 110 | - 'headers' => [ |
|
| 111 | - 'Accept' => 'application/dns-json' |
|
| 112 | - ] |
|
| 113 | - ]; |
|
| 114 | - |
|
| 115 | - try { |
|
| 116 | - $response = $this->client->get(null, $query); |
|
| 117 | - } catch (BadResponseException $e) { |
|
| 118 | - throw new RuntimeException("GET {$this->baseURI} failed", 0, $e); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $decode = json_decode($response->getBody()); |
|
| 122 | - |
|
| 123 | - if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 124 | - throw new RuntimeException( |
|
| 125 | - 'Attempted to decode expected JSON response, however server returned something unexpected.' |
|
| 126 | - ); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - return $decode; |
|
| 130 | - } |
|
| 42 | + const DNS_GOOGLE = 'https://dns.google.com/resolve'; |
|
| 43 | + const DNS_MOZILLA = 'https://mozilla.cloudflare-dns.com/dns-query'; |
|
| 44 | + const DNS_CLOUDFLARE = 'https://cloudflare-dns.com/dns-query'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * What DNS-over-HTTPS service to use |
|
| 48 | + * |
|
| 49 | + * @var null|string |
|
| 50 | + */ |
|
| 51 | + private $baseURI; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Guzzle client handler |
|
| 55 | + * |
|
| 56 | + * @var Client object |
|
| 57 | + */ |
|
| 58 | + private $client; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * DNSOverHTTPS constructor. |
|
| 62 | + * @param string|null $baseURI |
|
| 63 | + */ |
|
| 64 | + public function __construct(string $baseURI = null) |
|
| 65 | + { |
|
| 66 | + //Default to Google, seems like a safe bet... |
|
| 67 | + if ($baseURI === null) { |
|
| 68 | + $this->baseURI = self::DNS_GOOGLE; |
|
| 69 | + } else { |
|
| 70 | + $this->baseURI = $baseURI; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + $this->client = new Client([ |
|
| 74 | + 'base_uri' => $this->baseURI |
|
| 75 | + ]); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function checkChallenge($domain, $requiredDigest) : bool |
|
| 79 | + { |
|
| 80 | + $hostname = '_acme-challenge.' . str_replace('*.', '', $domain); |
|
| 81 | + |
|
| 82 | + $records = $this->get($hostname, 'TXT'); |
|
| 83 | + if ($records->Status == 0) { |
|
| 84 | + foreach ($records->Answer as $record) { |
|
| 85 | + if ((rtrim($record->name, ".") == $hostname) && |
|
| 86 | + ($record->type == 16) && |
|
| 87 | + (trim($record->data, '"') == $requiredDigest)) { |
|
| 88 | + return true; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @param string $name |
|
| 98 | + * @param string $type per experimental spec this can be string OR int, we force string |
|
| 99 | + * @return \stdClass |
|
| 100 | + */ |
|
| 101 | + public function get(string $name, string $type) : \stdClass |
|
| 102 | + { |
|
| 103 | + $query = [ |
|
| 104 | + 'query' => [ |
|
| 105 | + 'name' => $name, |
|
| 106 | + 'type' => $type, |
|
| 107 | + 'edns_client_subnet' => '0.0.0.0/0', //disable geotagged dns results |
|
| 108 | + 'ct' => 'application/dns-json', //cloudflare requires this |
|
| 109 | + ], |
|
| 110 | + 'headers' => [ |
|
| 111 | + 'Accept' => 'application/dns-json' |
|
| 112 | + ] |
|
| 113 | + ]; |
|
| 114 | + |
|
| 115 | + try { |
|
| 116 | + $response = $this->client->get(null, $query); |
|
| 117 | + } catch (BadResponseException $e) { |
|
| 118 | + throw new RuntimeException("GET {$this->baseURI} failed", 0, $e); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $decode = json_decode($response->getBody()); |
|
| 122 | + |
|
| 123 | + if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 124 | + throw new RuntimeException( |
|
| 125 | + 'Attempted to decode expected JSON response, however server returned something unexpected.' |
|
| 126 | + ); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + return $decode; |
|
| 130 | + } |
|
| 131 | 131 | } |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | 'query' => [ |
| 105 | 105 | 'name' => $name, |
| 106 | 106 | 'type' => $type, |
| 107 | - 'edns_client_subnet' => '0.0.0.0/0', //disable geotagged dns results |
|
| 107 | + 'edns_client_subnet' => '0.0.0.0/0', //disable geotagged dns results |
|
| 108 | 108 | 'ct' => 'application/dns-json', //cloudflare requires this |
| 109 | 109 | ], |
| 110 | 110 | 'headers' => [ |
@@ -10,14 +10,14 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | interface DNSValidatorInterface |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * This will strip any leading *. wildcard and prepend _acme-challenge. to form the challenge domain, |
|
| 15 | - * and will then request TXT record for that domain. If the record is found, and the content matches |
|
| 16 | - * the given digest, return true. Otherwise, return false |
|
| 17 | - * |
|
| 18 | - * @param $domain string base domain for certificate, which can include wildcard |
|
| 19 | - * @param $requiredDigest string expected digest value |
|
| 20 | - * @return bool |
|
| 21 | - */ |
|
| 22 | - public function checkChallenge($domain, $requiredDigest) : bool; |
|
| 13 | + /** |
|
| 14 | + * This will strip any leading *. wildcard and prepend _acme-challenge. to form the challenge domain, |
|
| 15 | + * and will then request TXT record for that domain. If the record is found, and the content matches |
|
| 16 | + * the given digest, return true. Otherwise, return false |
|
| 17 | + * |
|
| 18 | + * @param $domain string base domain for certificate, which can include wildcard |
|
| 19 | + * @param $requiredDigest string expected digest value |
|
| 20 | + * @return bool |
|
| 21 | + */ |
|
| 22 | + public function checkChallenge($domain, $requiredDigest) : bool; |
|
| 23 | 23 | } |
@@ -10,15 +10,15 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class NativeDNS implements DNSValidatorInterface |
| 12 | 12 | { |
| 13 | - public function checkChallenge($domain, $requiredDigest) : bool |
|
| 14 | - { |
|
| 15 | - $hostname = '_acme-challenge.' . str_replace('*.', '', $domain); |
|
| 16 | - $records = dns_get_record($hostname, DNS_TXT); |
|
| 17 | - foreach ($records as $record) { |
|
| 18 | - if ($record['host'] == $hostname && $record['type'] == 'TXT' && $record['txt'] == $requiredDigest) { |
|
| 19 | - return true; |
|
| 20 | - } |
|
| 21 | - } |
|
| 22 | - return false; |
|
| 23 | - } |
|
| 13 | + public function checkChallenge($domain, $requiredDigest) : bool |
|
| 14 | + { |
|
| 15 | + $hostname = '_acme-challenge.' . str_replace('*.', '', $domain); |
|
| 16 | + $records = dns_get_record($hostname, DNS_TXT); |
|
| 17 | + foreach ($records as $record) { |
|
| 18 | + if ($record['host'] == $hostname && $record['type'] == 'TXT' && $record['txt'] == $requiredDigest) { |
|
| 19 | + return true; |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | + return false; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public function checkChallenge($domain, $requiredDigest) : bool |
| 14 | 14 | { |
| 15 | 15 | $hostname = '_acme-challenge.' . str_replace('*.', '', $domain); |
| 16 | - $records = dns_get_record($hostname, DNS_TXT); |
|
| 16 | + $records = dns_get_record($hostname, DNS_TXT); |
|
| 17 | 17 | foreach ($records as $record) { |
| 18 | 18 | if ($record['host'] == $hostname && $record['type'] == 'TXT' && $record['txt'] == $requiredDigest) { |
| 19 | 19 | return true; |
@@ -10,8 +10,8 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Sleep |
| 12 | 12 | { |
| 13 | - public function for($seconds) |
|
| 14 | - { |
|
| 15 | - sleep($seconds); |
|
| 16 | - } |
|
| 13 | + public function for($seconds) |
|
| 14 | + { |
|
| 15 | + sleep($seconds); |
|
| 16 | + } |
|
| 17 | 17 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Sleep |
| 12 | 12 | { |
| 13 | - public function for($seconds) |
|
| 13 | + public function for ($seconds) |
|
| 14 | 14 | { |
| 15 | 15 | sleep($seconds); |
| 16 | 16 | } |