mirror of
https://github.com/anikeen-com/yaac.git
synced 2026-03-13 13:46:10 +00:00
naming changes
readme update
This commit is contained in:
@@ -194,7 +194,7 @@ class Client
|
||||
foreach ($domains as $domain) {
|
||||
$identifiers[] =
|
||||
[
|
||||
'type' => 'dns',
|
||||
'type' => 'dns',
|
||||
'value' => $domain,
|
||||
];
|
||||
}
|
||||
@@ -331,8 +331,8 @@ class Client
|
||||
$data['certificate'],
|
||||
$this->signPayloadKid(null, $data['certificate'])
|
||||
);
|
||||
$certificate = $str = preg_replace('/^[ \t]*[\r\n]+/m', '', (string)$certificateResponse->getBody());
|
||||
return new Certificate($privateKey, $csr, $certificate);
|
||||
$chain = $str = preg_replace('/^[ \t]*[\r\n]+/m', '', (string)$certificateResponse->getBody());
|
||||
return new Certificate($privateKey, $csr, $chain);
|
||||
}
|
||||
|
||||
|
||||
@@ -383,8 +383,8 @@ class Client
|
||||
protected function getSelfTestClient()
|
||||
{
|
||||
return new HttpClient([
|
||||
'verify' => false,
|
||||
'timeout' => 10,
|
||||
'verify' => false,
|
||||
'timeout' => 10,
|
||||
'connect_timeout' => 3,
|
||||
'allow_redirects' => true,
|
||||
]);
|
||||
@@ -459,9 +459,9 @@ class Client
|
||||
protected function getSelfTestDNSClient()
|
||||
{
|
||||
return new HttpClient([
|
||||
'base_uri' => 'https://cloudflare-dns.com',
|
||||
'base_uri' => 'https://cloudflare-dns.com',
|
||||
'connect_timeout' => 10,
|
||||
'headers' => [
|
||||
'headers' => [
|
||||
'Accept' => 'application/dns-json',
|
||||
],
|
||||
]);
|
||||
@@ -511,7 +511,7 @@ class Client
|
||||
$this->getUrl(self::DIRECTORY_NEW_ACCOUNT),
|
||||
$this->signPayloadJWK(
|
||||
[
|
||||
'contact' => [
|
||||
'contact' => [
|
||||
'mailto:' . $this->getOption('username'),
|
||||
],
|
||||
'termsOfServiceAgreed' => true,
|
||||
@@ -590,7 +590,7 @@ class Client
|
||||
{
|
||||
try {
|
||||
$response = $this->getHttpClient()->request($method, $url, [
|
||||
'json' => $payload,
|
||||
'json' => $payload,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/jose+json',
|
||||
]
|
||||
@@ -650,9 +650,9 @@ class Client
|
||||
protected function getJWKHeader(): array
|
||||
{
|
||||
return [
|
||||
'e' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['e']),
|
||||
'e' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['e']),
|
||||
'kty' => 'RSA',
|
||||
'n' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['n']),
|
||||
'n' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['n']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -671,10 +671,10 @@ class Client
|
||||
$this->nonce = $response->getHeaderLine('replay-nonce');
|
||||
}
|
||||
return [
|
||||
'alg' => 'RS256',
|
||||
'jwk' => $this->getJWKHeader(),
|
||||
'alg' => 'RS256',
|
||||
'jwk' => $this->getJWKHeader(),
|
||||
'nonce' => $this->nonce,
|
||||
'url' => $url
|
||||
'url' => $url
|
||||
];
|
||||
}
|
||||
|
||||
@@ -691,10 +691,10 @@ class Client
|
||||
$nonce = $response->getHeaderLine('replay-nonce');
|
||||
|
||||
return [
|
||||
"alg" => "RS256",
|
||||
"kid" => $this->account->getAccountURL(),
|
||||
"alg" => "RS256",
|
||||
"kid" => $this->account->getAccountURL(),
|
||||
"nonce" => $nonce,
|
||||
"url" => $url
|
||||
"url" => $url
|
||||
];
|
||||
}
|
||||
|
||||
@@ -720,7 +720,7 @@ class Client
|
||||
|
||||
return [
|
||||
'protected' => $protected,
|
||||
'payload' => $payload,
|
||||
'payload' => $payload,
|
||||
'signature' => Helper::toSafeString($signature),
|
||||
];
|
||||
}
|
||||
@@ -746,7 +746,7 @@ class Client
|
||||
|
||||
return [
|
||||
'protected' => $protected,
|
||||
'payload' => $payload,
|
||||
'payload' => $payload,
|
||||
'signature' => Helper::toSafeString($signature),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ class Certificate
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $certificate;
|
||||
protected $chain;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $certificateNoChain;
|
||||
protected $certificate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -41,16 +41,16 @@ class Certificate
|
||||
* Certificate constructor.
|
||||
* @param $privateKey
|
||||
* @param $csr
|
||||
* @param $certificate
|
||||
* @param $chain
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($privateKey, $csr, $certificate)
|
||||
public function __construct($privateKey, $csr, $chain)
|
||||
{
|
||||
$this->privateKey = $privateKey;
|
||||
$this->csr = $csr;
|
||||
$this->certificate = $certificate;
|
||||
list($this->certificateNoChain, $this->intermediateCertificate) = Helper::splitCertificate($certificate);
|
||||
$this->expiryDate = Helper::getCertExpiryDate($certificate);
|
||||
$this->chain = $chain;
|
||||
list($this->certificate, $this->intermediateCertificate) = Helper::splitCertificate($chain);
|
||||
$this->expiryDate = Helper::getCertExpiryDate($chain);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,19 +72,21 @@ class Certificate
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the certificate as a multi line string
|
||||
* Return the certificate as a multi line string, by default it includes the intermediate certificate as well
|
||||
*
|
||||
* @param bool $asChain
|
||||
* @return string
|
||||
*/
|
||||
public function getCertificate($asChain = true): string
|
||||
{
|
||||
return $asChain ? $this->certificate : $this->certificateNoChain;
|
||||
return $asChain ? $this->chain : $this->certificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the intermediate certificate as a multi line string
|
||||
* @return string
|
||||
*/
|
||||
public function getIntermediateCertificate(): string
|
||||
public function getIntermediate(): string
|
||||
{
|
||||
return $this->intermediateCertificate;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class Helper
|
||||
/**
|
||||
* Get a new CSR
|
||||
*
|
||||
* @param array $domains
|
||||
* @param array $domains
|
||||
* @param $key
|
||||
*
|
||||
* @return string
|
||||
@@ -81,8 +81,8 @@ class Helper
|
||||
'[v3_req]',
|
||||
'[v3_ca]',
|
||||
'[SAN]',
|
||||
'subjectAltName='.implode(',', array_map(function ($domain) {
|
||||
return 'DNS:'.$domain;
|
||||
'subjectAltName=' . implode(',', array_map(function ($domain) {
|
||||
return 'DNS:' . $domain;
|
||||
}, $domains)),
|
||||
];
|
||||
|
||||
@@ -90,11 +90,11 @@ class Helper
|
||||
file_put_contents($fn, implode("\n", $config));
|
||||
$csr = openssl_csr_new([
|
||||
'countryName' => 'NL',
|
||||
'commonName' => $primaryDomain,
|
||||
'commonName' => $primaryDomain,
|
||||
], $key, [
|
||||
'config' => $fn,
|
||||
'config' => $fn,
|
||||
'req_extensions' => 'SAN',
|
||||
'digest_alg' => 'sha512',
|
||||
'digest_alg' => 'sha512',
|
||||
]);
|
||||
unlink($fn);
|
||||
|
||||
@@ -140,23 +140,27 @@ class Helper
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a two certificate bundle into separate
|
||||
* multi line string certificates
|
||||
* Split a two certificate bundle into separate multi line string certificates
|
||||
* @param string $chain
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function splitCertificate(string $certificate): array
|
||||
public static function splitCertificate(string $chain): array
|
||||
{
|
||||
preg_match('/^(?<signed>-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----)\n'
|
||||
.'(?<intermediate>-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----)$/s',
|
||||
$certificate, $certificates);
|
||||
preg_match(
|
||||
'/^(?<domain>-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----)\n'
|
||||
. '(?<intermediate>-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----)$/s',
|
||||
$chain,
|
||||
$certificates
|
||||
);
|
||||
|
||||
$signed = $certificates['signed'] ?? null;
|
||||
$domain = $certificates['domain'] ?? null;
|
||||
$intermediate = $certificates['intermediate'] ?? null;
|
||||
|
||||
if (!$signed || !$intermediate) {
|
||||
if (!$domain || !$intermediate) {
|
||||
throw new \Exception('Could not parse certificate string');
|
||||
}
|
||||
|
||||
return [$signed, $intermediate];
|
||||
return [$domain, $intermediate];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user