applied getOption

psr2 formatting
This commit is contained in:
peterbakker
2022-02-18 16:09:56 +01:00
parent d5827cb970
commit 1d1797ded5

View File

@@ -138,11 +138,6 @@ class Client
$this->init();
}
public function getKeyLength(): int
{
return $this->config['key_length'] ?? 4096;
}
/**
* Get an existing order by ID
*
@@ -200,7 +195,7 @@ class Client
foreach ($domains as $domain) {
$identifiers[] =
[
'type' => 'dns',
'type' => 'dns',
'value' => $domain,
];
}
@@ -287,7 +282,7 @@ class Client
* @return bool
* @throws \Exception
*/
public function validate(Challenge $challenge, $maxAttempts = 15): bool
public function validate(Challenge $challenge, int $maxAttempts = 15): bool
{
$this->request(
$challenge->getUrl(),
@@ -321,7 +316,7 @@ class Client
*/
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);
$der = Helper::toDer($csr);
@@ -394,8 +389,8 @@ class Client
protected function getSelfTestClient()
{
return new HttpClient([
'verify' => false,
'timeout' => 10,
'verify' => false,
'timeout' => 10,
'connect_timeout' => 3,
'allow_redirects' => true,
]);
@@ -470,9 +465,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',
],
]);
@@ -498,7 +493,10 @@ class Client
{
//Make sure a private key is in place
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 = openssl_pkey_get_private($privateKey);
@@ -516,7 +514,7 @@ class Client
$this->getUrl(self::DIRECTORY_NEW_ACCOUNT),
$this->signPayloadJWK(
[
'contact' => [
'contact' => [
'mailto:' . $this->getOption('username'),
],
'termsOfServiceAgreed' => true,
@@ -537,9 +535,9 @@ class Client
$userDirectory = preg_replace('/[^a-z0-9]+/', '-', strtolower($this->getOption('username')));
return $this->getOption(
'basePath',
'le'
) . DIRECTORY_SEPARATOR . $userDirectory . ($path === null ? '' : DIRECTORY_SEPARATOR . $path);
'basePath',
'le'
) . DIRECTORY_SEPARATOR . $userDirectory . ($path === null ? '' : DIRECTORY_SEPARATOR . $path);
}
/**
@@ -595,7 +593,7 @@ class Client
{
try {
$response = $this->getHttpClient()->request($method, $url, [
'json' => $payload,
'json' => $payload,
'headers' => [
'Content-Type' => 'application/jose+json',
]
@@ -655,9 +653,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']),
];
}
@@ -676,10 +674,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
];
}
@@ -696,10 +694,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
];
}
@@ -725,7 +723,7 @@ class Client
return [
'protected' => $protected,
'payload' => $payload,
'payload' => $payload,
'signature' => Helper::toSafeString($signature),
];
}
@@ -751,7 +749,7 @@ class Client
return [
'protected' => $protected,
'payload' => $payload,
'payload' => $payload,
'signature' => Helper::toSafeString($signature),
];
}