mirror of
https://github.com/anikeen-com/yaac.git
synced 2026-03-19 08:36:11 +00:00
applied getOption
psr2 formatting
This commit is contained in:
@@ -138,11 +138,6 @@ class Client
|
|||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKeyLength(): int
|
|
||||||
{
|
|
||||||
return $this->config['key_length'] ?? 4096;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an existing order by ID
|
* Get an existing order by ID
|
||||||
*
|
*
|
||||||
@@ -200,7 +195,7 @@ class Client
|
|||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
$identifiers[] =
|
$identifiers[] =
|
||||||
[
|
[
|
||||||
'type' => 'dns',
|
'type' => 'dns',
|
||||||
'value' => $domain,
|
'value' => $domain,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -287,7 +282,7 @@ class Client
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function validate(Challenge $challenge, $maxAttempts = 15): bool
|
public function validate(Challenge $challenge, int $maxAttempts = 15): bool
|
||||||
{
|
{
|
||||||
$this->request(
|
$this->request(
|
||||||
$challenge->getUrl(),
|
$challenge->getUrl(),
|
||||||
@@ -321,7 +316,7 @@ class Client
|
|||||||
*/
|
*/
|
||||||
public function getCertificate(Order $order): Certificate
|
public function getCertificate(Order $order): Certificate
|
||||||
{
|
{
|
||||||
$privateKey = Helper::getNewKey($this->getKeyLength());
|
$privateKey = Helper::getNewKey($this->getOption('key_length', 4096));
|
||||||
$csr = Helper::getCsr($order->getDomains(), $privateKey);
|
$csr = Helper::getCsr($order->getDomains(), $privateKey);
|
||||||
$der = Helper::toDer($csr);
|
$der = Helper::toDer($csr);
|
||||||
|
|
||||||
@@ -394,8 +389,8 @@ class Client
|
|||||||
protected function getSelfTestClient()
|
protected function getSelfTestClient()
|
||||||
{
|
{
|
||||||
return new HttpClient([
|
return new HttpClient([
|
||||||
'verify' => false,
|
'verify' => false,
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'connect_timeout' => 3,
|
'connect_timeout' => 3,
|
||||||
'allow_redirects' => true,
|
'allow_redirects' => true,
|
||||||
]);
|
]);
|
||||||
@@ -470,9 +465,9 @@ class Client
|
|||||||
protected function getSelfTestDNSClient()
|
protected function getSelfTestDNSClient()
|
||||||
{
|
{
|
||||||
return new HttpClient([
|
return new HttpClient([
|
||||||
'base_uri' => 'https://cloudflare-dns.com',
|
'base_uri' => 'https://cloudflare-dns.com',
|
||||||
'connect_timeout' => 10,
|
'connect_timeout' => 10,
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Accept' => 'application/dns-json',
|
'Accept' => 'application/dns-json',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
@@ -498,7 +493,10 @@ class Client
|
|||||||
{
|
{
|
||||||
//Make sure a private key is in place
|
//Make sure a private key is in place
|
||||||
if ($this->getFilesystem()->has($this->getPath('account.pem')) === false) {
|
if ($this->getFilesystem()->has($this->getPath('account.pem')) === false) {
|
||||||
$this->getFilesystem()->write($this->getPath('account.pem'), Helper::getNewKey($this->getKeyLength()));
|
$this->getFilesystem()->write(
|
||||||
|
$this->getPath('account.pem'),
|
||||||
|
Helper::getNewKey($this->getOption('key_length', 4096))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$privateKey = $this->getFilesystem()->read($this->getPath('account.pem'));
|
$privateKey = $this->getFilesystem()->read($this->getPath('account.pem'));
|
||||||
$privateKey = openssl_pkey_get_private($privateKey);
|
$privateKey = openssl_pkey_get_private($privateKey);
|
||||||
@@ -516,7 +514,7 @@ class Client
|
|||||||
$this->getUrl(self::DIRECTORY_NEW_ACCOUNT),
|
$this->getUrl(self::DIRECTORY_NEW_ACCOUNT),
|
||||||
$this->signPayloadJWK(
|
$this->signPayloadJWK(
|
||||||
[
|
[
|
||||||
'contact' => [
|
'contact' => [
|
||||||
'mailto:' . $this->getOption('username'),
|
'mailto:' . $this->getOption('username'),
|
||||||
],
|
],
|
||||||
'termsOfServiceAgreed' => true,
|
'termsOfServiceAgreed' => true,
|
||||||
@@ -537,9 +535,9 @@ class Client
|
|||||||
$userDirectory = preg_replace('/[^a-z0-9]+/', '-', strtolower($this->getOption('username')));
|
$userDirectory = preg_replace('/[^a-z0-9]+/', '-', strtolower($this->getOption('username')));
|
||||||
|
|
||||||
return $this->getOption(
|
return $this->getOption(
|
||||||
'basePath',
|
'basePath',
|
||||||
'le'
|
'le'
|
||||||
) . DIRECTORY_SEPARATOR . $userDirectory . ($path === null ? '' : DIRECTORY_SEPARATOR . $path);
|
) . DIRECTORY_SEPARATOR . $userDirectory . ($path === null ? '' : DIRECTORY_SEPARATOR . $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -595,7 +593,7 @@ class Client
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = $this->getHttpClient()->request($method, $url, [
|
$response = $this->getHttpClient()->request($method, $url, [
|
||||||
'json' => $payload,
|
'json' => $payload,
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Content-Type' => 'application/jose+json',
|
'Content-Type' => 'application/jose+json',
|
||||||
]
|
]
|
||||||
@@ -655,9 +653,9 @@ class Client
|
|||||||
protected function getJWKHeader(): array
|
protected function getJWKHeader(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'e' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['e']),
|
'e' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['e']),
|
||||||
'kty' => 'RSA',
|
'kty' => 'RSA',
|
||||||
'n' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['n']),
|
'n' => Helper::toSafeString(Helper::getKeyDetails($this->getAccountKey())['rsa']['n']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,10 +674,10 @@ class Client
|
|||||||
$this->nonce = $response->getHeaderLine('replay-nonce');
|
$this->nonce = $response->getHeaderLine('replay-nonce');
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'alg' => 'RS256',
|
'alg' => 'RS256',
|
||||||
'jwk' => $this->getJWKHeader(),
|
'jwk' => $this->getJWKHeader(),
|
||||||
'nonce' => $this->nonce,
|
'nonce' => $this->nonce,
|
||||||
'url' => $url
|
'url' => $url
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,10 +694,10 @@ class Client
|
|||||||
$nonce = $response->getHeaderLine('replay-nonce');
|
$nonce = $response->getHeaderLine('replay-nonce');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"alg" => "RS256",
|
"alg" => "RS256",
|
||||||
"kid" => $this->account->getAccountURL(),
|
"kid" => $this->account->getAccountURL(),
|
||||||
"nonce" => $nonce,
|
"nonce" => $nonce,
|
||||||
"url" => $url
|
"url" => $url
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,7 +723,7 @@ class Client
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'protected' => $protected,
|
'protected' => $protected,
|
||||||
'payload' => $payload,
|
'payload' => $payload,
|
||||||
'signature' => Helper::toSafeString($signature),
|
'signature' => Helper::toSafeString($signature),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -751,7 +749,7 @@ class Client
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'protected' => $protected,
|
'protected' => $protected,
|
||||||
'payload' => $payload,
|
'payload' => $payload,
|
||||||
'signature' => Helper::toSafeString($signature),
|
'signature' => Helper::toSafeString($signature),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user