/** * {@inheritdoc} */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { $recordName = $this->extractor->getRecordName($authorizationChallenge); $this->output->writeln(sprintf(<<<'EOF' You can now cleanup your DNS by removing the domain <comment>_acme-challenge.%s.</comment> EOF , $recordName)); }
/** * {@inheritdoc} */ public function isValid(AuthorizationChallenge $authorizationChallenge) { $recordName = $this->extractor->getRecordName($authorizationChallenge); $recordValue = $this->extractor->getRecordValue($authorizationChallenge); foreach (dns_get_record($recordName, DNS_TXT) as $record) { if (in_array($recordValue, $record['entries'])) { return true; } } return false; }
public function testGetRecordName() { $domain = 'foo.com'; $mockEncoder = $this->prophesize(Base64SafeEncoder::class); $stubChallenge = $this->prophesize(AuthorizationChallenge::class); $extractor = new DnsDataExtractor($mockEncoder->reveal()); $stubChallenge->getDomain()->willReturn($domain); $this->assertEquals('_acme-challenge.' . $domain . '.', $extractor->getRecordName($stubChallenge->reveal())); }