mirror of
https://github.com/anikeen-com/yaac.git
synced 2026-03-13 13:46:10 +00:00
added dns support
This commit is contained in:
@@ -122,13 +122,20 @@ class Authorization
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DNS record object
|
||||
*
|
||||
* @param Challenge $challenge
|
||||
* @return string containing TXT record for DNS challenge
|
||||
* @return Record|bool
|
||||
*/
|
||||
public function getTxtRecord(Challenge $challenge)
|
||||
public function getTxtRecord()
|
||||
{
|
||||
$raw=$challenge->getToken() . '.' . $this->digest;
|
||||
$hash=hash('sha256', $raw, true);
|
||||
return Helper::toSafeString($hash);
|
||||
$challenge = $this->getDnsChallenge();
|
||||
if ($challenge !== false) {
|
||||
$hash = hash('sha256', $challenge->getToken() . '.' . $this->digest, true);
|
||||
$value = Helper::toSafeString($hash);
|
||||
return new Record('_acme-challenge.' . $this->getDomain(), $value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
46
src/Data/Record.php
Normal file
46
src/Data/Record.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Afosto\Acme\Data;
|
||||
|
||||
class Record
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* Record constructor.
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct(string $name, string $value)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DNS TXT record name for validation
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the record value for DNS validation
|
||||
* @return string
|
||||
*/
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user