コード例 #1
0
ファイル: DnsValidator.php プロジェクト: acmephp/core
 /**
  * {@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;
 }
コード例 #2
0
ファイル: SimpleDnsSolver.php プロジェクト: acmephp/core
    /**
     * {@inheritdoc}
     */
    public function solve(AuthorizationChallenge $authorizationChallenge)
    {
        $recordName = $this->extractor->getRecordName($authorizationChallenge);
        $recordValue = $this->extractor->getRecordValue($authorizationChallenge);
        $this->output->writeln(sprintf(<<<'EOF'
    Add the following TXT record to your DNS zone
        Domain: %s
        TXT value: %s
        
    <comment>Wait for the propagation before moving to the next step</comment>
    Tips: Use the following command to check the propagation

        host -t TXT %s

EOF
, $recordName, $recordValue, $recordName));
    }
コード例 #3
0
 public function testGetRecordValue()
 {
     $payload = 'randomPayload';
     $encodedPayload = 'encodedSHA256Payload';
     $mockEncoder = $this->prophesize(Base64SafeEncoder::class);
     $stubChallenge = $this->prophesize(AuthorizationChallenge::class);
     $extractor = new DnsDataExtractor($mockEncoder->reveal());
     $stubChallenge->getPayload()->willReturn($payload);
     $mockEncoder->encode(hash('sha256', $payload, true))->willReturn($encodedPayload);
     $this->assertEquals($encodedPayload, $extractor->getRecordValue($stubChallenge->reveal()));
 }