private function doVerifyChallenge($domain, $expectedPayload)
{
if (!is_string($domain)) {
throw new InvalidArgumentException(sprintf("\$domain must be of type string, %s given.", gettype($domain)));
}
if (!is_string($expectedPayload)) {
throw new InvalidArgumentException(sprintf("\$expectedPayload must be of type string, %s given.", gettype($expectedPayload)));
}
$uri = "_acme-challenge." . $domain;
try {
$dnsResponse = (yield $this->resolver->query($uri, ["types" => Record::TXT]));
} catch (NoRecordException $e) {
throw new AcmeException("Verification failed, no TXT record found for '{$uri}'.", 0, $e);
} catch (ResolutionException $e) {
throw new AcmeException("Verification failed, couldn't query TXT record of '{$uri}': " . $e->getMessage(), 0, $e);
}
list($record) = $dnsResponse;
list($payload) = $record;
if ($payload !== $expectedPayload) {
throw new AcmeException("Verification failed, please check DNS record under '{$uri}'. Expected: '{$expectedPayload}', Got: '{$payload}'.");
}
(yield new CoroutineResult($dnsResponse));
return;
}