From ee2119ee81b2057a2c817884fecb1243afb19229 Mon Sep 17 00:00:00 2001 From: mjaglewicz Date: Thu, 30 Sep 2021 18:30:06 +0200 Subject: [PATCH 01/77] Cpanel certificate installation action --- src/Cli/Action/InstallCPanelAction.php | 58 ++++++++++++++++++++++++++ src/Cli/Resources/services.xml | 4 ++ 2 files changed, 62 insertions(+) create mode 100644 src/Cli/Action/InstallCPanelAction.php diff --git a/src/Cli/Action/InstallCPanelAction.php b/src/Cli/Action/InstallCPanelAction.php new file mode 100644 index 00000000..6efbdc95 --- /dev/null +++ b/src/Cli/Action/InstallCPanelAction.php @@ -0,0 +1,58 @@ +httpClient = $httpClient; + } + + /** + * {@inheritdoc} + */ + public function handle(array $config, CertificateResponse $response) + { + $this->assertConfiguration($config, ['host', 'username', 'token']); + + $commonName = $response->getCertificateRequest()->getDistinguishedName()->getCommonName(); + $certificate = $response->getCertificate(); + $privateKey = $response->getCertificateRequest()->getKeyPair()->getPrivateKey(); + + $issuerChain = array_map(function (Certificate $certificate) { + return $certificate->getPEM(); + }, $certificate->getIssuerChain()); + + $this->installCertificate( + $config, + $commonName, + $certificate->getPEM(), + implode("\n", $issuerChain), + $privateKey->getPEM() + ); + } + + private function installCertificate($config, $domain, $crt, $caBundle, $key) + { + $this->httpClient->request('POST', $config['host'] . 'json-api/cpanel?' . + 'cpanel_jsonapi_apiversion=2&' . + 'cpanel_jsonapi_module=SSL&' . + 'cpanel_jsonapi_func=installssl&' . + 'domain=' . $domain . '&' . + 'crt=' . urlencode($crt) . '&' . + 'key=' . urlencode($key) . '&' . + 'cabundle=' . urlencode($caBundle), + ['headers' => ['Authorization' => 'cpanel ' . $config['username'] . ':' . $config['token']], + ]); + } +} \ No newline at end of file diff --git a/src/Cli/Resources/services.xml b/src/Cli/Resources/services.xml index 15e3b5b9..d347e0ca 100644 --- a/src/Cli/Resources/services.xml +++ b/src/Cli/Resources/services.xml @@ -96,6 +96,10 @@ + + + + From 2299602e5b619f12cdf4aa5df923a65b81d86b1e Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Wed, 5 Jan 2022 11:28:14 +0100 Subject: [PATCH 02/77] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 75088a6b..389a42d2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ Acme PHP ======== [![Build Status](https://img.shields.io/travis/acmephp/acmephp/master.svg?style=flat-square)](https://travis-ci.org/acmephp/acmephp) -[![StyleCI](https://styleci.io/repos/59910490/shield)](https://styleci.io/repos/59910490) [![Packagist Version](https://img.shields.io/packagist/v/acmephp/acmephp.svg?style=flat-square)](https://packagist.org/packages/acmephp/acmephp) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) @@ -18,8 +17,7 @@ able to deeply integrate the management of your certificates directly in your ap by these features, have a look at the [acmephp/core](https://github.com/acmephp/core) and [acmephp/ssl](https://github.com/acmephp/ssl) libraries. -> If you want to chat with us or have questions, ping -> @tgalopin or @jderusse on the [Symfony Slack](https://symfony.com/support)! +> Acme PHP is now maintained by https://zerossl.com. ## Why should I use Acme PHP when I have an official client? From 76213560564720e11089feea47aa5ba9d87be83f Mon Sep 17 00:00:00 2001 From: Hans Adema Date: Wed, 1 Dec 2021 11:43:15 +0100 Subject: [PATCH 03/77] Fix tests on PHP 8.0/8.1 --- .github/workflows/test-build.yaml | 17 ++++++++++ src/Ssl/Key.php | 2 +- tests/Ssl/AssertsOpenSslResource.php | 33 ++++++++++++++++++ tests/Ssl/CertificateTest.php | 4 ++- tests/Ssl/Generator/KeyPairGeneratorTest.php | 35 +++++++++++--------- 5 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 tests/Ssl/AssertsOpenSslResource.php diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index eb2af741..4f472c25 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -64,3 +64,20 @@ jobs: run: ./tests/setup.sh - name: Running tests run: ./tests/run.sh + + tests-php80-deps-high-pebble-eab: + runs-on: ubuntu-latest + env: + PEBBLE_MODE: eab + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + - uses: actions/checkout@master + - name: Install dependencies + run: composer update --no-interaction --no-progress --ansi --prefer-stable + - name: Preparing tests + run: ./tests/setup.sh + - name: Running tests + run: ./tests/run.sh + diff --git a/src/Ssl/Key.php b/src/Ssl/Key.php index 6614ffb8..6852ce24 100644 --- a/src/Ssl/Key.php +++ b/src/Ssl/Key.php @@ -47,7 +47,7 @@ public function getDER(): string } /** - * @return resource + * @return resource|\OpenSSLAsymmetricKey */ abstract public function getResource(); } diff --git a/tests/Ssl/AssertsOpenSslResource.php b/tests/Ssl/AssertsOpenSslResource.php new file mode 100644 index 00000000..47e19307 --- /dev/null +++ b/tests/Ssl/AssertsOpenSslResource.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Tests\AcmePhp\Ssl; + +use PHPUnit\Framework\Assert; + +trait AssertsOpenSslResource +{ + /** + * Asserts that the provided "resource" is an OpenSSL Assymetric Key. + * + * On PHP 8+, OpenSSL works with objects. On PHP <8 OpenSSL works with resources. + * + * @param resource|\OpenSSLAsymmetricKey $resource + */ + public function assertIsOpenSslAsymmetricKey($resource) + { + if (PHP_MAJOR_VERSION >= 8) { + Assert::assertInstanceOf(\OpenSSLAsymmetricKey::class, $resource); + } else { + Assert::assertIsResource($resource); + } + } +} diff --git a/tests/Ssl/CertificateTest.php b/tests/Ssl/CertificateTest.php index 2202b96d..12fe63c9 100644 --- a/tests/Ssl/CertificateTest.php +++ b/tests/Ssl/CertificateTest.php @@ -17,6 +17,8 @@ class CertificateTest extends TestCase { + use AssertsOpenSslResource; + public function test_getPublicKey_returns_a_PublicKey() { $certificate = new Certificate( @@ -102,6 +104,6 @@ public function test_getPublicKeyResource_returns_a_resource() $resource = $certificate->getPublicKeyResource(); - $this->assertIsResource($resource); + $this->assertIsOpenSslAsymmetricKey($resource); } } diff --git a/tests/Ssl/Generator/KeyPairGeneratorTest.php b/tests/Ssl/Generator/KeyPairGeneratorTest.php index 10ae5812..1c6739d4 100644 --- a/tests/Ssl/Generator/KeyPairGeneratorTest.php +++ b/tests/Ssl/Generator/KeyPairGeneratorTest.php @@ -18,9 +18,12 @@ use AcmePhp\Ssl\Generator\RsaKey\RsaKeyOption; use AcmePhp\Ssl\KeyPair; use PHPUnit\Framework\TestCase; +use Tests\AcmePhp\Ssl\AssertsOpenSslResource; class KeyPairGeneratorTest extends TestCase { + use AssertsOpenSslResource; + /** @var KeyPairGenerator */ private $service; @@ -36,14 +39,14 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair() $result = $this->service->generateKeyPair(new RsaKeyOption(1024)); $this->assertInstanceOf(KeyPair::class, $result); - $this->assertStringContainsString('-----BEGIN PUBLIC KEY-----', $result->getPublicKey()->getPEM()); - $this->assertStringContainsString('-----BEGIN PRIVATE KEY-----', $result->getPrivateKey()->getPEM()); - $this->assertIsResource($result->getPublicKey()->getResource()); - $this->assertIsResource($result->getPrivateKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPublicKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPrivateKey()->getResource()); $details = openssl_pkey_get_details($result->getPrivateKey()->getResource()); $this->assertEquals(1024, $details['bits']); $this->assertArrayHasKey('rsa', $details); + + $this->assertEquals($details['key'], $result->getPublicKey()->getPEM()); } public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_DH() @@ -54,13 +57,13 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_D )); $this->assertInstanceOf(KeyPair::class, $result); - $this->assertStringContainsString('-----BEGIN PUBLIC KEY-----', $result->getPublicKey()->getPEM()); - $this->assertStringContainsString('-----BEGIN PRIVATE KEY-----', $result->getPrivateKey()->getPEM()); - $this->assertIsResource($result->getPublicKey()->getResource()); - $this->assertIsResource($result->getPrivateKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPublicKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPrivateKey()->getResource()); $details = openssl_pkey_get_details($result->getPrivateKey()->getResource()); $this->assertArrayHasKey('dh', $details); + + $this->assertEquals($details['key'], $result->getPublicKey()->getPEM()); } public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_DSA() @@ -68,14 +71,14 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_D $result = $this->service->generateKeyPair(new DsaKeyOption(1024)); $this->assertInstanceOf(KeyPair::class, $result); - $this->assertStringContainsString('-----BEGIN PUBLIC KEY-----', $result->getPublicKey()->getPEM()); - $this->assertStringContainsString('-----BEGIN PRIVATE KEY-----', $result->getPrivateKey()->getPEM()); - $this->assertIsResource($result->getPublicKey()->getResource()); - $this->assertIsResource($result->getPrivateKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPublicKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPrivateKey()->getResource()); $details = openssl_pkey_get_details($result->getPrivateKey()->getResource()); $this->assertEquals(1024, $details['bits']); $this->assertArrayHasKey('dsa', $details); + + $this->assertEquals($details['key'], $result->getPublicKey()->getPEM()); } /** @@ -86,14 +89,14 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_E $result = $this->service->generateKeyPair(new EcKeyOption('secp112r1')); $this->assertInstanceOf(KeyPair::class, $result); - $this->assertStringContainsString('-----BEGIN PUBLIC KEY-----', $result->getPublicKey()->getPEM()); - $this->assertStringContainsString('-----BEGIN EC PRIVATE KEY-----', $result->getPrivateKey()->getPEM()); - $this->assertIsResource($result->getPublicKey()->getResource()); - $this->assertIsResource($result->getPrivateKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPublicKey()->getResource()); + $this->assertIsOpenSslAsymmetricKey($result->getPrivateKey()->getResource()); $details = openssl_pkey_get_details($result->getPrivateKey()->getResource()); $this->assertEquals(112, $details['bits']); $this->assertArrayHasKey('ec', $details); $this->assertEquals('secp112r1', $details['ec']['curve_name']); + + $this->assertEquals($details['key'], $result->getPublicKey()->getPEM()); } } From 2755d98e75c73706f180a5641adc9bac1f8bcff5 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Tue, 31 May 2022 18:46:13 +0200 Subject: [PATCH 04/77] Add PHP 8.1 tests and fix deprecations --- .github/workflows/test-build.yaml | 15 +++++++++++++++ src/Core/Http/SecureHttpClient.php | 8 +++++--- tests/Core/Challenge/Http/HttpValidatorTest.php | 5 ++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 4f472c25..116c935a 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -81,3 +81,18 @@ jobs: - name: Running tests run: ./tests/run.sh + tests-php81-deps-high-pebble-eab: + runs-on: ubuntu-latest + env: + PEBBLE_MODE: eab + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + - uses: actions/checkout@master + - name: Install dependencies + run: composer update --no-interaction --no-progress --ansi --prefer-stable + - name: Preparing tests + run: ./tests/setup.sh + - name: Running tests + run: ./tests/run.sh diff --git a/src/Core/Http/SecureHttpClient.php b/src/Core/Http/SecureHttpClient.php index d53f873a..7a2a0ed7 100644 --- a/src/Core/Http/SecureHttpClient.php +++ b/src/Core/Http/SecureHttpClient.php @@ -26,6 +26,7 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Utils; use Lcobucci\JWT\Signer\Hmac\Sha256; +use Lcobucci\JWT\Signer\Key\InMemory; use Psr\Http\Message\ResponseInterface; /** @@ -172,9 +173,10 @@ public function createExternalAccountPayload(ExternalAccount $externalAccount, s $encodedProtected = $this->base64Encoder->encode(json_encode($protected, JSON_UNESCAPED_SLASHES)); $encodedPayload = $this->base64Encoder->encode(json_encode($this->getJWK(), JSON_UNESCAPED_SLASHES)); - $signature = $this->base64Encoder->encode( - (string) $signer->sign($encodedProtected.'.'.$encodedPayload, $this->base64Encoder->decode($externalAccount->getHmacKey())) - ); + $hmacKey = $this->base64Encoder->decode($externalAccount->getHmacKey()); + $hmacKey = class_exists(InMemory::class) ? InMemory::plainText($hmacKey) : $hmacKey; + + $signature = $this->base64Encoder->encode((string) $signer->sign($encodedProtected.'.'.$encodedPayload, $hmacKey)); return [ 'protected' => $encodedProtected, diff --git a/tests/Core/Challenge/Http/HttpValidatorTest.php b/tests/Core/Challenge/Http/HttpValidatorTest.php index 98cf691f..116fbe45 100644 --- a/tests/Core/Challenge/Http/HttpValidatorTest.php +++ b/tests/Core/Challenge/Http/HttpValidatorTest.php @@ -79,10 +79,13 @@ public function testIsValidCatchExceptions() $mockExtractor->getCheckUrl($stubChallenge->reveal())->willReturn($checkUrl); $mockExtractor->getCheckContent($stubChallenge->reveal())->willReturn($checkContent); + $mockResponse = $this->prophesize(ResponseInterface::class); + $mockResponse->getStatusCode()->willReturn(400); + $mockHttpClient->get($checkUrl, ['verify' => false])->willThrow(new ClientException( 'boom', $this->prophesize(RequestInterface::class)->reveal(), - $this->prophesize(ResponseInterface::class)->reveal() + $mockResponse->reveal() )); $this->assertFalse($validator->isValid($stubChallenge->reveal(), $this->prophesize(SolverInterface::class)->reveal())); From 2cfc866bafa9395cf38ad684ef40868713eafb0a Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Tue, 31 May 2022 19:09:48 +0200 Subject: [PATCH 05/77] Allow Symfony 6 --- .github/workflows/test-build.yaml | 69 +++++++++++++++++++++++++----- composer.json | 23 +++++----- src/Cli/Application.php | 5 ++- src/Cli/Serializer/PemEncoder.php | 4 +- src/Core/Http/SecureHttpClient.php | 4 +- 5 files changed, 76 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 116c935a..4269520e 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -13,86 +13,135 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: '7.2' + coverage: none + - uses: actions/checkout@master + - name: php-cs-fixer run: | wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -q php php-cs-fixer.phar fix --dry-run --diff - tests-php72-deps-low-pebble-default: + tests-php72-sf50-low: runs-on: ubuntu-latest + env: + SYMFONY_VERSION: 5.0.* steps: - uses: shivammathur/setup-php@v2 with: php-version: '7.2' + coverage: none + - uses: actions/checkout@master + - name: Install dependencies run: | composer require --dev "sebastian/comparator:^2.0" + composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION + composer require --no-update --dev symfony/finder=$SYMFONY_VERSION composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable + - name: Preparing tests run: ./tests/setup.sh + - name: Running tests run: ./tests/run.sh - tests-php73-deps-lock-pebble-default: + tests-php73-sf54-low: runs-on: ubuntu-latest + env: + SYMFONY_VERSION: 5.4.* steps: - uses: shivammathur/setup-php@v2 with: php-version: '7.3' + coverage: none + - uses: actions/checkout@master + - name: Install dependencies - run: composer install + run: | + composer require --dev "sebastian/comparator:^2.0" + composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION + composer require --no-update --dev symfony/finder=$SYMFONY_VERSION + composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable + - name: Preparing tests run: ./tests/setup.sh + - name: Running tests run: ./tests/run.sh - tests-php74-deps-high-pebble-eab: + tests-php74-sf54-high-eab: runs-on: ubuntu-latest env: + SYMFONY_VERSION: 5.4.* PEBBLE_MODE: eab steps: - uses: shivammathur/setup-php@v2 with: php-version: '7.4' + coverage: none + - uses: actions/checkout@master + - name: Install dependencies - run: composer update --no-interaction --no-progress --ansi --prefer-stable + run: | + composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION + composer require --no-update --dev symfony/finder=$SYMFONY_VERSION + composer update --no-interaction --no-progress --ansi --prefer-stable + - name: Preparing tests run: ./tests/setup.sh + - name: Running tests run: ./tests/run.sh - tests-php80-deps-high-pebble-eab: + tests-php80-sf60-high: runs-on: ubuntu-latest env: - PEBBLE_MODE: eab + SYMFONY_VERSION: 6.0.* steps: - uses: shivammathur/setup-php@v2 with: php-version: '8.0' + coverage: none + - uses: actions/checkout@master + - name: Install dependencies - run: composer update --no-interaction --no-progress --ansi --prefer-stable + run: | + composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION + composer require --no-update --dev symfony/finder=$SYMFONY_VERSION + composer update --no-interaction --no-progress --ansi --prefer-stable + - name: Preparing tests run: ./tests/setup.sh + - name: Running tests run: ./tests/run.sh - tests-php81-deps-high-pebble-eab: + tests-php81-sf61-high-eab: runs-on: ubuntu-latest env: + SYMFONY_VERSION: 6.1.* PEBBLE_MODE: eab steps: - uses: shivammathur/setup-php@v2 with: php-version: '8.1' + coverage: none + - uses: actions/checkout@master + - name: Install dependencies - run: composer update --no-interaction --no-progress --ansi --prefer-stable + run: | + composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION + composer require --no-update --dev symfony/finder=$SYMFONY_VERSION + composer update --no-interaction --no-progress --ansi --prefer-stable + - name: Preparing tests run: ./tests/setup.sh + - name: Running tests run: ./tests/run.sh diff --git a/composer.json b/composer.json index d9942c84..73f9f258 100644 --- a/composer.json +++ b/composer.json @@ -56,12 +56,12 @@ "psr/http-message": "^1.0", "psr/log": "^1.0", "swiftmailer/swiftmailer": "^5.4|^6.0", - "symfony/config": "^5.0", - "symfony/console": "^5.0", - "symfony/dependency-injection": "^5.0", - "symfony/filesystem": "^5.0", - "symfony/serializer": "^5.0", - "symfony/yaml": "^5.0", + "symfony/config": "^5.0|^6.0", + "symfony/console": "^5.0|^6.0", + "symfony/dependency-injection": "^5.0|^6.0", + "symfony/filesystem": "^5.0|^6.0", + "symfony/serializer": "^5.0|^6.0", + "symfony/yaml": "^5.0|^6.0", "webmozart/assert": "^1.0", "webmozart/path-util": "^2.3" }, @@ -70,9 +70,9 @@ }, "require-dev": { "phpspec/prophecy": "^1.9", - "symfony/finder": "^5.0", - "symfony/phpunit-bridge": "^5.0", - "symfony/var-dumper": "^5.0" + "symfony/finder": "^5.0|^6.0", + "symfony/phpunit-bridge": "^5.0|^6.0", + "symfony/var-dumper": "^5.0|^6.0" }, "autoload": { "psr-4": { @@ -85,9 +85,6 @@ } }, "config": { - "sort-packages": true, - "platform": { - "php": "7.2.34" - } + "sort-packages": true } } diff --git a/src/Cli/Application.php b/src/Cli/Application.php index caf03a68..19bb14db 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -17,6 +17,7 @@ use AcmePhp\Cli\Command\SelfUpdateCommand; use AcmePhp\Cli\Command\StatusCommand; use Symfony\Component\Console\Application as BaseApplication; +use Symfony\Component\Console\Helper\HelperSet; use Webmozart\PathUtil\Path; /** @@ -41,7 +42,7 @@ public function __construct() /** * {@inheritdoc} */ - protected function getDefaultCommands() + protected function getDefaultCommands(): array { return array_merge(parent::getDefaultCommands(), [ new RunCommand(), @@ -54,7 +55,7 @@ protected function getDefaultCommands() /** * {@inheritdoc} */ - protected function getDefaultHelperSet() + protected function getDefaultHelperSet(): HelperSet { $set = parent::getDefaultHelperSet(); $set->set(new DistinguishedNameHelper()); diff --git a/src/Cli/Serializer/PemEncoder.php b/src/Cli/Serializer/PemEncoder.php index d5f8d117..d9f15c35 100644 --- a/src/Cli/Serializer/PemEncoder.php +++ b/src/Cli/Serializer/PemEncoder.php @@ -24,7 +24,7 @@ class PemEncoder implements EncoderInterface, DecoderInterface /** * {@inheritdoc} */ - public function encode($data, $format, array $context = []) + public function encode($data, $format, array $context = []): string { return trim($data)."\n"; } @@ -40,7 +40,7 @@ public function decode($data, $format, array $context = []) /** * {@inheritdoc} */ - public function supportsEncoding($format) + public function supportsEncoding($format): bool { return self::FORMAT === $format; } diff --git a/src/Core/Http/SecureHttpClient.php b/src/Core/Http/SecureHttpClient.php index 7a2a0ed7..acb05b59 100644 --- a/src/Core/Http/SecureHttpClient.php +++ b/src/Core/Http/SecureHttpClient.php @@ -165,7 +165,7 @@ public function createExternalAccountPayload(ExternalAccount $externalAccount, s $signer = new Sha256(); $protected = [ - 'alg' => $signer->getAlgorithmId(), + 'alg' => method_exists($signer, 'algorithmId') ? $signer->algorithmId() : $signer->getAlgorithmId(), 'kid' => $externalAccount->getId(), 'url' => $url, ]; @@ -176,7 +176,7 @@ public function createExternalAccountPayload(ExternalAccount $externalAccount, s $hmacKey = $this->base64Encoder->decode($externalAccount->getHmacKey()); $hmacKey = class_exists(InMemory::class) ? InMemory::plainText($hmacKey) : $hmacKey; - $signature = $this->base64Encoder->encode((string) $signer->sign($encodedProtected.'.'.$encodedPayload, $hmacKey)); + $signature = $this->base64Encoder->encode($signer->sign($encodedProtected.'.'.$encodedPayload, $hmacKey)); return [ 'protected' => $encodedProtected, From 043fd6cd896597d2c05a9565ab620a045b57f8ef Mon Sep 17 00:00:00 2001 From: Thomas Bickley Date: Wed, 10 Mar 2021 16:04:52 +0000 Subject: [PATCH 06/77] Allow Monolog version 2 --- composer.json | 2 +- src/Cli/Monolog/ConsoleFormatter.php | 2 +- src/Cli/Monolog/ConsoleHandler.php | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 73f9f258..9692dad7 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "league/flysystem": "^1.0.19", "league/flysystem-memory": "^1.0", "league/flysystem-sftp": "^1.0.7", - "monolog/monolog": "^1.19", + "monolog/monolog": "^1.19|^2.0", "padraic/phar-updater": "^1.0", "psr/container": "^1.0", "psr/http-message": "^1.0", diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index 21fda4ca..8cb29c2b 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -38,7 +38,7 @@ public function __construct($format = null, $dateFormat = null, $allowInlineLine /** * {@inheritdoc} */ - public function format(array $record) + public function format(array $record): string { if ($record['level'] >= Logger::ERROR) { $record['start_tag'] = ''; diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index 94692863..45cc8bde 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -11,6 +11,7 @@ namespace AcmePhp\Cli\Monolog; +use Monolog\Formatter\FormatterInterface; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Logger; use Symfony\Component\Console\Output\OutputInterface; @@ -65,7 +66,7 @@ public function __construct(OutputInterface $output = null, bool $bubble = true, /** * {@inheritdoc} */ - public function isHandling(array $record) + public function isHandling(array $record): bool { return $this->updateLevel() && parent::isHandling($record); } @@ -73,7 +74,7 @@ public function isHandling(array $record) /** * {@inheritdoc} */ - public function handle(array $record) + public function handle(array $record): bool { // we have to update the logging level each time because the verbosity of the // console output might have changed in the meantime (it is not immutable) @@ -93,7 +94,7 @@ public function setOutput(OutputInterface $output) /** * Disables the output. */ - public function close() + public function close(): void { $this->output = null; @@ -103,7 +104,7 @@ public function close() /** * {@inheritdoc} */ - protected function write(array $record) + protected function write(array $record): void { $this->output->write((string) $record['formatted']); } @@ -111,7 +112,7 @@ protected function write(array $record) /** * {@inheritdoc} */ - protected function getDefaultFormatter() + protected function getDefaultFormatter(): FormatterInterface { $formatter = new ConsoleFormatter(); $formatter->allowInlineLineBreaks(); From d685b932967c9b992791d7f54e98161c6d9ef229 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 1 Jan 2022 23:37:09 +0100 Subject: [PATCH 07/77] Fix badges in README --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 389a42d2..7ec35b55 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ Acme PHP ======== -[![Build Status](https://img.shields.io/travis/acmephp/acmephp/master.svg?style=flat-square)](https://travis-ci.org/acmephp/acmephp) +[![Build Status](https://img.shields.io/github/workflow/status/acmephp/acmephp/Test%20and%20build?style=flat-square)](https://github.com/acmephp/acmephp/actions?query=branch%3Amaster+workflow%3A%22Test+and+build%22) [![Packagist Version](https://img.shields.io/packagist/v/acmephp/acmephp.svg?style=flat-square)](https://packagist.org/packages/acmephp/acmephp) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![SymfonyInsight](https://insight.symfony.com/projects/4eb121bf-9f9d-4d16-813b-f98f07003eaf/big.svg)](https://insight.symfony.com/projects/4eb121bf-9f9d-4d16-813b-f98f07003eaf) - Acme PHP is a simple yet very extensible CLI client for Let's Encrypt that will help you get and renew free HTTPS certificates. From 2ae3edf26314a1d626f83cac97608cee553f3523 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Tue, 31 May 2022 19:28:37 +0200 Subject: [PATCH 08/77] Upgrade PHP-CS-Fixer --- .github/workflows/test-build.yaml | 11 +++++---- .gitignore | 2 +- .php-cs-fixer.dist.php | 26 ++++++++++++++++++++ .php_cs | 40 ------------------------------- 4 files changed, 33 insertions(+), 46 deletions(-) create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .php_cs diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 4269520e..a3af626f 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -12,15 +12,16 @@ jobs: steps: - uses: shivammathur/setup-php@v2 with: - php-version: '7.2' + php-version: '8.1' coverage: none - uses: actions/checkout@master - - name: php-cs-fixer - run: | - wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -q - php php-cs-fixer.phar fix --dry-run --diff + - name: Install php-cs-fixer + run: wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.4.0/php-cs-fixer.phar -q + + - name: Check coding style + run: php php-cs-fixer.phar fix --dry-run --diff tests-php72-sf50-low: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index afc37e8d..a3c77191 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ /box.json composer.lock vendor/ -.php_cs.cache +.php-cs-fixer.cache doc/.couscous .subsplit .phpunit.result.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..be3821f3 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,26 @@ + + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +EOF; + +$finder = PhpCsFixer\Finder::create() + ->in(__DIR__.'/bin') + ->in(__DIR__.'/src') + ->in(__DIR__.'/tests') +; + +return (new PhpCsFixer\Config()) + ->setFinder($finder) + ->setRules([ + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'phpdoc_annotation_without_dot' => false, + 'header_comment' => ['header' => $header], + ]) +; diff --git a/.php_cs b/.php_cs deleted file mode 100644 index acd8b667..00000000 --- a/.php_cs +++ /dev/null @@ -1,40 +0,0 @@ - - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. -EOF; - -$config = PhpCsFixer\Config::create() - ->setRiskyAllowed(true) - ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => true, - 'header_comment' => ['header' => $header], - 'linebreak_after_opening_tag' => true, - 'modernize_types_casting' => true, - 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], - 'no_superfluous_elseif' => true, - 'no_useless_else' => true, - 'phpdoc_order' => true, - 'psr4' => true, - 'simplified_null_return' => true, - 'no_useless_return' => true, - 'strict_comparison' => true, - 'yoda_style' => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__.'/') - ->exclude('vendor') - ->name('*.php') - ) -; - -return $config; From 182d539c113d86de07050e19ce6fc2bae44e1784 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Tue, 31 May 2022 19:29:05 +0200 Subject: [PATCH 09/77] Fix CS --- src/Cli/Command/SelfUpdateCommand.php | 8 ++++---- src/Cli/Monolog/ConsoleFormatter.php | 2 +- tests/Ssl/CertificateTest.php | 4 ++-- tests/Ssl/Generator/KeyPairGeneratorTest.php | 8 ++++---- tests/Ssl/Parser/CertificateParserTest.php | 6 +++--- tests/Ssl/Parser/KeyParserTest.php | 12 ++++++------ tests/Ssl/PrivateKeyTest.php | 6 +++--- tests/Ssl/PublicKeyTest.php | 6 +++--- tests/Ssl/Signer/CertificateRequestSignerTest.php | 6 +++--- tests/Ssl/Signer/DataSignerTest.php | 4 ++-- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/Cli/Command/SelfUpdateCommand.php b/src/Cli/Command/SelfUpdateCommand.php index bb11a37f..b2f03b33 100644 --- a/src/Cli/Command/SelfUpdateCommand.php +++ b/src/Cli/Command/SelfUpdateCommand.php @@ -29,10 +29,10 @@ */ class SelfUpdateCommand extends Command { - const PACKAGE_NAME = 'acmephp/acmephp'; - const FILE_NAME = 'acmephp.phar'; - const VERSION_URL = 'https://acmephp.github.io/downloads/acmephp.version'; - const PHAR_URL = 'https://acmephp.github.io/downloads/acmephp.phar'; + public const PACKAGE_NAME = 'acmephp/acmephp'; + public const FILE_NAME = 'acmephp.phar'; + public const VERSION_URL = 'https://acmephp.github.io/downloads/acmephp.version'; + public const PHAR_URL = 'https://acmephp.github.io/downloads/acmephp.phar'; /** * @var string diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index 8cb29c2b..e9ad5281 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -25,7 +25,7 @@ */ class ConsoleFormatter extends LineFormatter { - const SIMPLE_FORMAT = "%start_tag%%message% %context% %extra%%end_tag%\n"; + public const SIMPLE_FORMAT = "%start_tag%%message% %context% %extra%%end_tag%\n"; /** * {@inheritdoc} diff --git a/tests/Ssl/CertificateTest.php b/tests/Ssl/CertificateTest.php index 12fe63c9..24b0a4c2 100644 --- a/tests/Ssl/CertificateTest.php +++ b/tests/Ssl/CertificateTest.php @@ -19,7 +19,7 @@ class CertificateTest extends TestCase { use AssertsOpenSslResource; - public function test_getPublicKey_returns_a_PublicKey() + public function testGetPublicKeyReturnsAPublicKey() { $certificate = new Certificate( ' @@ -63,7 +63,7 @@ public function test_getPublicKey_returns_a_PublicKey() $this->assertEquals('58b94e38ce0088f0ec5a0c38f04bd76c', md5($publicKey->getPEM())); } - public function test_getPublicKeyResource_returns_a_resource() + public function testGetPublicKeyResourceReturnsAResource() { $certificate = new Certificate( ' diff --git a/tests/Ssl/Generator/KeyPairGeneratorTest.php b/tests/Ssl/Generator/KeyPairGeneratorTest.php index 1c6739d4..49df2602 100644 --- a/tests/Ssl/Generator/KeyPairGeneratorTest.php +++ b/tests/Ssl/Generator/KeyPairGeneratorTest.php @@ -34,7 +34,7 @@ public function setUp(): void $this->service = new KeyPairGenerator(); } - public function test_generateKeyPair_generate_random_instance_of_KeyPair() + public function testGenerateKeyPairGenerateRandomInstanceOfKeyPair() { $result = $this->service->generateKeyPair(new RsaKeyOption(1024)); @@ -49,7 +49,7 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair() $this->assertEquals($details['key'], $result->getPublicKey()->getPEM()); } - public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_DH() + public function testGenerateKeyPairGenerateRandomInstanceOfKeyPairUsingDH() { $result = $this->service->generateKeyPair(new DhKeyOption( 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61ef75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683705577d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e3826634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab', @@ -66,7 +66,7 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_D $this->assertEquals($details['key'], $result->getPublicKey()->getPEM()); } - public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_DSA() + public function testGenerateKeyPairGenerateRandomInstanceOfKeyPairUsingDSA() { $result = $this->service->generateKeyPair(new DsaKeyOption(1024)); @@ -84,7 +84,7 @@ public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_D /** * @requires PHP 7.1 */ - public function test_generateKeyPair_generate_random_instance_of_KeyPair_using_EC() + public function testGenerateKeyPairGenerateRandomInstanceOfKeyPairUsingEC() { $result = $this->service->generateKeyPair(new EcKeyOption('secp112r1')); diff --git a/tests/Ssl/Parser/CertificateParserTest.php b/tests/Ssl/Parser/CertificateParserTest.php index 06fe6a37..7b82373e 100644 --- a/tests/Ssl/Parser/CertificateParserTest.php +++ b/tests/Ssl/Parser/CertificateParserTest.php @@ -28,13 +28,13 @@ public function setUp(): void $this->service = new CertificateParser(); } - public function test_parse_raise_proper_exception() + public function testParseRaiseProperException() { $this->expectException('AcmePhp\Ssl\Exception\CertificateParsingException'); $this->service->parse(new Certificate('Not a cert')); } - public function test_parse_returns_instance_of_ParsedCertificate() + public function testParseReturnsInstanceOfParsedCertificate() { $result = $this->service->parse( new Certificate( @@ -88,7 +88,7 @@ public function test_parse_returns_instance_of_ParsedCertificate() $this->assertFalse($result->isSelfSigned()); } - public function test_parse_without_issuer_CN_returns_instance_of_ParsedCertificate() + public function testParseWithoutIssuerCNReturnsInstanceOfParsedCertificate() { $result = $this->service->parse( new Certificate( diff --git a/tests/Ssl/Parser/KeyParserTest.php b/tests/Ssl/Parser/KeyParserTest.php index 991ede29..93e8a4e4 100644 --- a/tests/Ssl/Parser/KeyParserTest.php +++ b/tests/Ssl/Parser/KeyParserTest.php @@ -30,30 +30,30 @@ public function setUp(): void $this->service = new KeyParser(); } - public function test_parse_PublicKey_raise_proper_exception() + public function testParsePublicKeyRaiseProperException() { $this->expectException('AcmePhp\Ssl\Exception\KeyParsingException'); $this->service->parse(new PublicKey('Not a key')); } - public function test_parse_PrivateKey_raise_proper_exception() + public function testParsePrivateKeyRaiseProperException() { $this->expectException('AcmePhp\Ssl\Exception\KeyParsingException'); $this->service->parse(new PrivateKey('Not a key')); } - public function test_get_PrivateKey_has_invalid_detail() + public function testGetPrivateKeyHasInvalidDetail() { $this->assertFalse($this->service->parse($this->getPrivateKey())->hasDetail('invalid')); } - public function test_get_PrivateKey_get_invalid_detail_raise_proper_exception() + public function testGetPrivateKeyGetInvalidDetailRaiseProperException() { $this->expectException('InvalidArgumentException'); $this->service->parse($this->getPrivateKey())->getDetail('invalid'); } - public function test_parse_PrivateKey_returns_instance_of_ParsedKey() + public function testParsePrivateKeyReturnsInstanceOfParsedKey() { $result = $this->service->parse($this->getPrivateKey()); @@ -67,7 +67,7 @@ public function test_parse_PrivateKey_returns_instance_of_ParsedKey() $this->assertEquals(trim($this->getPublicKey()->getPEM()), trim($result->getKey())); } - public function test_parse_PublicKey_returns_instance_of_ParsedKey() + public function testParsePublicKeyReturnsInstanceOfParsedKey() { $result = $this->service->parse($this->getPublicKey()); diff --git a/tests/Ssl/PrivateKeyTest.php b/tests/Ssl/PrivateKeyTest.php index bd3cd155..e59cbe50 100644 --- a/tests/Ssl/PrivateKeyTest.php +++ b/tests/Ssl/PrivateKeyTest.php @@ -17,7 +17,7 @@ class PrivateKeyTest extends TestCase { - public function test_getPublicKey_returns_a_PublicKey() + public function testGetPublicKeyReturnsAPublicKey() { $privateKey = new PrivateKey('-----BEGIN PRIVATE KEY----- MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDH3IKV8sJZZHGd @@ -78,7 +78,7 @@ public function test_getPublicKey_returns_a_PublicKey() $this->assertEquals('80969771cf03d0331d1911810feff5fc', md5($publicKey->getPEM())); } - public function test_fromDER_returns_a_PrivateKey() + public function testFromDERReturnsAPrivateKey() { $derb64 = 'MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDH3IKV8sJZZHGd Q0vUN9GHJACixg8N1wFpUe763HmnWwiyCFHK9YjOfxkDSRK+2lP72Ns+RTBwtM8s @@ -137,7 +137,7 @@ public function test_fromDER_returns_a_PrivateKey() $this->assertEquals('a6dcb8eaae257961d2ee888899f087ef', md5($privateKey->getPEM())); } - public function test_getDER_returns_a_string() + public function testGetDERReturnsAString() { $privateKey = new PrivateKey('-----BEGIN PRIVATE KEY----- MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDH3IKV8sJZZHGd diff --git a/tests/Ssl/PublicKeyTest.php b/tests/Ssl/PublicKeyTest.php index bc4034fe..ac44e63a 100644 --- a/tests/Ssl/PublicKeyTest.php +++ b/tests/Ssl/PublicKeyTest.php @@ -16,7 +16,7 @@ class PublicKeyTest extends TestCase { - public function test_fromDER_returns_a_PublicKey() + public function testFromDERReturnsAPublicKey() { $derb64 = 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAx9yClfLCWWRxnUNL1DfR hyQAosYPDdcBaVHu+tx5p1sIsghRyvWIzn8ZA0kSvtpT+9jbPkUwcLTPLGW0SAC8 @@ -37,7 +37,7 @@ public function test_fromDER_returns_a_PublicKey() $this->assertEquals('48fa4235a71c704c815363702d7effbb', md5($publicKey->getPEM())); } - public function test_getDER_returns_a_string() + public function testGetDERReturnsAString() { $publicKey = new PublicKey('-----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAx9yClfLCWWRxnUNL1DfR @@ -60,7 +60,7 @@ public function test_getDER_returns_a_string() $this->assertEquals('d2ea173bab74794037c74653b65433af', md5($der)); } - public function test_getHPKP_returns_a_string() + public function testGetHPKPReturnsAString() { $publicKey = new PublicKey('-----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAx9yClfLCWWRxnUNL1DfR diff --git a/tests/Ssl/Signer/CertificateRequestSignerTest.php b/tests/Ssl/Signer/CertificateRequestSignerTest.php index bb9a660b..473d6e6b 100644 --- a/tests/Ssl/Signer/CertificateRequestSignerTest.php +++ b/tests/Ssl/Signer/CertificateRequestSignerTest.php @@ -30,7 +30,7 @@ public function setUp(): void $this->service = new CertificateRequestSigner(); } - public function test_signCertificateRequest_returns_a_certificate() + public function testSignCertificateRequestReturnsACertificate() { $dummyDistinguishedName = new DistinguishedName( 'acmephp.com', @@ -59,7 +59,7 @@ public function test_signCertificateRequest_returns_a_certificate() ); } - public function test_signCertificateRequest_use_default_values() + public function testSignCertificateRequestUseDefaultValues() { $dummyDistinguishedName = new DistinguishedName( 'acmephp.com' @@ -80,7 +80,7 @@ public function test_signCertificateRequest_use_default_values() ); } - public function test_signCertificateRequest_with_subject_alternative_names() + public function testSignCertificateRequestWithSubjectAlternativeNames() { $dummyDistinguishedName = new DistinguishedName( 'acmephp.com', diff --git a/tests/Ssl/Signer/DataSignerTest.php b/tests/Ssl/Signer/DataSignerTest.php index fce80d15..cf54d1a6 100644 --- a/tests/Ssl/Signer/DataSignerTest.php +++ b/tests/Ssl/Signer/DataSignerTest.php @@ -30,7 +30,7 @@ public function setUp(): void $this->service = new DataSigner(); } - public function test_signData_returns_a_signature() + public function testSignDataReturnsASignature() { $privateRsaKey = (new RsaKeyGenerator())->generatePrivateKey(new RsaKeyOption()); @@ -51,7 +51,7 @@ public function test_signData_returns_a_signature() /** * @requires PHP 7.1 */ - public function test_signData_returns_a_signature_for_ec_keys() + public function testSignDataReturnsASignatureForEcKeys() { $this->assertEquals(64, \strlen($this->service->signData('foo', (new EcKeyGenerator())->generatePrivateKey(new EcKeyOption('prime256v1')), OPENSSL_ALGO_SHA256, DataSigner::FORMAT_ECDSA))); $this->assertEquals(96, \strlen($this->service->signData('foo', (new EcKeyGenerator())->generatePrivateKey(new EcKeyOption('secp384r1')), OPENSSL_ALGO_SHA384, DataSigner::FORMAT_ECDSA))); From 03d14b353ef16c9af40d7de0803ac52dc31319d1 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 1 Jan 2022 22:49:53 +0100 Subject: [PATCH 10/77] Remove unused swiftmailer dependency --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 9692dad7..a358b3c8 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,6 @@ "psr/container": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0", - "swiftmailer/swiftmailer": "^5.4|^6.0", "symfony/config": "^5.0|^6.0", "symfony/console": "^5.0|^6.0", "symfony/dependency-injection": "^5.0|^6.0", From d345ffe46edaaa64f5d8f99f3ca7729342101ac4 Mon Sep 17 00:00:00 2001 From: Mike Griego Date: Thu, 24 Feb 2022 12:15:02 -0600 Subject: [PATCH 11/77] Allow for newer dependencies and fix a couple of issues in AcmePhp\Core. --- src/Core/AcmeClient.php | 8 ++++++-- src/Core/Http/SecureHttpClient.php | 2 +- src/Core/Http/ServerErrorHandler.php | 5 +++-- src/Core/composer.json | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Core/AcmeClient.php b/src/Core/AcmeClient.php index 77b8618a..1d2c897d 100644 --- a/src/Core/AcmeClient.php +++ b/src/Core/AcmeClient.php @@ -327,9 +327,13 @@ protected function requestResource(string $method, string $resource, array $payl private function createCertificateResponse(CertificateRequest $csr, string $certificate): CertificateResponse { + $certificateHeader = '-----BEGIN CERTIFICATE-----'; $certificatesChain = null; - foreach (array_reverse(explode("\n\n", $certificate)) as $pem) { - $certificatesChain = new Certificate($pem, $certificatesChain); + + foreach (array_reverse(explode($certificateHeader, $certificate)) as $pem) { + if (\trim($pem) !== '') { + $certificatesChain = new Certificate($certificateHeader . $pem, $certificatesChain); + } } return new CertificateResponse($csr, $certificatesChain); diff --git a/src/Core/Http/SecureHttpClient.php b/src/Core/Http/SecureHttpClient.php index acb05b59..efcd7cd0 100644 --- a/src/Core/Http/SecureHttpClient.php +++ b/src/Core/Http/SecureHttpClient.php @@ -211,7 +211,7 @@ public function request(string $method, string $endpoint, array $data = [], bool $data = JsonDecoder::decode($body, true); } catch (\InvalidArgumentException $exception) { - throw new ExpectedJsonException(sprintf('ACME client excepted valid JSON as a response to request "%s %s" (given: "%s")', $method, $endpoint, ServerErrorHandler::getResponseBodySummary($response)), $exception); + throw new ExpectedJsonException(sprintf('ACME client expected valid JSON as a response to request "%s %s" (given: "%s")', $method, $endpoint, ServerErrorHandler::getResponseBodySummary($response)), $exception); } return $data; diff --git a/src/Core/Http/ServerErrorHandler.php b/src/Core/Http/ServerErrorHandler.php index 9b40c768..b161fa70 100644 --- a/src/Core/Http/ServerErrorHandler.php +++ b/src/Core/Http/ServerErrorHandler.php @@ -33,6 +33,7 @@ use AcmePhp\Core\Exception\Server\UserActionRequiredServerException; use AcmePhp\Core\Util\JsonDecoder; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -80,7 +81,7 @@ public static function getResponseBodySummary(ResponseInterface $response): stri return RequestException::getResponseBodySummary($response); } - $body = \GuzzleHttp\Psr7\copy_to_string($response->getBody()); + $body = Utils::copyToString($response->getBody()); if (\strlen($body) > 120) { return substr($body, 0, 120).' (truncated...)'; @@ -94,7 +95,7 @@ public function createAcmeExceptionForResponse( ResponseInterface $response, \Exception $previous = null ): AcmeCoreServerException { - $body = \GuzzleHttp\Psr7\copy_to_string($response->getBody()); + $body = Utils::copyToString($response->getBody()); try { $data = JsonDecoder::decode($body, true); diff --git a/src/Core/composer.json b/src/Core/composer.json index 8e72fda8..2e82021a 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -33,10 +33,10 @@ "ext-openssl": "*", "acmephp/ssl": "^2.0", "guzzlehttp/guzzle": "^6.0|^7.0", - "guzzlehttp/psr7": "^1.0", + "guzzlehttp/psr7": "^1.7|^2.1", "lcobucci/jwt": "^3.3|^4.0", "psr/http-message": "^1.0", - "psr/log": "^1.0", + "psr/log": "^1.0|^2.0|^3.0", "webmozart/assert": "^1.0" }, "autoload": { From 09e4bead6167f601b2060da36a0c36ab1e73d0e8 Mon Sep 17 00:00:00 2001 From: Mike Griego Date: Thu, 10 Mar 2022 09:57:04 -0600 Subject: [PATCH 12/77] Serialize embedded authorization challenges when serializing order objects. --- src/Core/AcmeClient.php | 4 ++-- src/Core/Protocol/CertificateOrder.php | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Core/AcmeClient.php b/src/Core/AcmeClient.php index 1d2c897d..709ceebf 100644 --- a/src/Core/AcmeClient.php +++ b/src/Core/AcmeClient.php @@ -331,8 +331,8 @@ private function createCertificateResponse(CertificateRequest $csr, string $cert $certificatesChain = null; foreach (array_reverse(explode($certificateHeader, $certificate)) as $pem) { - if (\trim($pem) !== '') { - $certificatesChain = new Certificate($certificateHeader . $pem, $certificatesChain); + if ('' !== \trim($pem)) { + $certificatesChain = new Certificate($certificateHeader.$pem, $certificatesChain); } } diff --git a/src/Core/Protocol/CertificateOrder.php b/src/Core/Protocol/CertificateOrder.php index a18236c3..8f343e2c 100644 --- a/src/Core/Protocol/CertificateOrder.php +++ b/src/Core/Protocol/CertificateOrder.php @@ -42,8 +42,20 @@ public function __construct(array $authorizationsChallenges, string $orderEndpoi public function toArray(): array { + $authorizationsChallenges = array_map( + function ($challenges): array { + return array_map( + function ($challenge): array { + return $challenge->toArray(); + }, + $challenges + ); + }, + $this->getAuthorizationsChallenges() + ); + return [ - 'authorizationsChallenges' => $this->getAuthorizationsChallenges(), + 'authorizationsChallenges' => $authorizationsChallenges, 'orderEndpoint' => $this->getOrderEndpoint(), ]; } From 95c17a4156843e2ddb404fc0cd83dbd6a342a81b Mon Sep 17 00:00:00 2001 From: Hans Adema Date: Wed, 1 Dec 2021 11:31:53 +0100 Subject: [PATCH 13/77] Add Core\AcmeClient::reloadOrder method The reloadOrder method refreshes CertificateOrder information from the CA. This is useful if the CA returned a server error, and you need to retrieve what has been done. Also add the order status property to the CertificateOrder object to check this. --- src/Core/AcmeClient.php | 27 +++++++++++++++++++++++++- src/Core/AcmeClientInterface.php | 5 +++++ src/Core/Protocol/CertificateOrder.php | 12 +++++++++++- tests/Core/AcmeClientTest.php | 10 ++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/Core/AcmeClient.php b/src/Core/AcmeClient.php index 709ceebf..24a9fb31 100644 --- a/src/Core/AcmeClient.php +++ b/src/Core/AcmeClient.php @@ -140,7 +140,32 @@ static function ($domain) { } } - return new CertificateOrder($authorizationsChallenges, $orderEndpoint); + return new CertificateOrder($authorizationsChallenges, $orderEndpoint, $response['status']); + } + + /** + * {@inheritdoc} + */ + public function reloadOrder(CertificateOrder $order): CertificateOrder + { + $client = $this->getHttpClient(); + $orderEndpoint = $order->getOrderEndpoint(); + $response = $client->request('POST', $orderEndpoint, $client->signKidPayload($orderEndpoint, $this->getResourceAccount(), null)); + + if (!isset($response['authorizations']) || !$response['authorizations']) { + throw new ChallengeNotSupportedException(); + } + + $authorizationsChallenges = []; + foreach ($response['authorizations'] as $authorizationEndpoint) { + $authorizationsResponse = $client->request('POST', $authorizationEndpoint, $client->signKidPayload($authorizationEndpoint, $this->getResourceAccount(), null)); + $domain = (empty($authorizationsResponse['wildcard']) ? '' : '*.').$authorizationsResponse['identifier']['value']; + foreach ($authorizationsResponse['challenges'] as $challenge) { + $authorizationsChallenges[$domain][] = $this->createAuthorizationChallenge($authorizationsResponse['identifier']['value'], $challenge); + } + } + + return new CertificateOrder($authorizationsChallenges, $orderEndpoint, $response['status']); } /** diff --git a/src/Core/AcmeClientInterface.php b/src/Core/AcmeClientInterface.php index f307fb7b..e035bbd7 100644 --- a/src/Core/AcmeClientInterface.php +++ b/src/Core/AcmeClientInterface.php @@ -66,6 +66,11 @@ public function registerAccount(string $email = null, ExternalAccount $externalA */ public function requestOrder(array $domains): CertificateOrder; + /** + * Request the current status of a certificate order. + */ + public function reloadOrder(CertificateOrder $order): CertificateOrder; + /** * Request a certificate for the given domain. * diff --git a/src/Core/Protocol/CertificateOrder.php b/src/Core/Protocol/CertificateOrder.php index 8f343e2c..a78bd830 100644 --- a/src/Core/Protocol/CertificateOrder.php +++ b/src/Core/Protocol/CertificateOrder.php @@ -26,7 +26,10 @@ class CertificateOrder /** @var string */ private $orderEndpoint; - public function __construct(array $authorizationsChallenges, string $orderEndpoint = null) + /** @var string */ + private $status; + + public function __construct(array $authorizationsChallenges, string $orderEndpoint = null, string $status = null) { foreach ($authorizationsChallenges as &$authorizationChallenges) { foreach ($authorizationChallenges as &$authorizationChallenge) { @@ -38,6 +41,7 @@ public function __construct(array $authorizationsChallenges, string $orderEndpoi $this->authorizationsChallenges = $authorizationsChallenges; $this->orderEndpoint = $orderEndpoint; + $this->status = $status; } public function toArray(): array @@ -57,6 +61,7 @@ function ($challenge): array { return [ 'authorizationsChallenges' => $authorizationsChallenges, 'orderEndpoint' => $this->getOrderEndpoint(), + 'status' => $this->getStatus(), ]; } @@ -89,4 +94,9 @@ public function getOrderEndpoint(): string { return $this->orderEndpoint; } + + public function getStatus(): string + { + return $this->status; + } } diff --git a/tests/Core/AcmeClientTest.php b/tests/Core/AcmeClientTest.php index 39383e73..1ba447c5 100644 --- a/tests/Core/AcmeClientTest.php +++ b/tests/Core/AcmeClientTest.php @@ -76,6 +76,7 @@ public function testFullProcess(KeyOption $keyOption, bool $useAlternateCertific * Ask for domain challenge */ $order = $client->requestOrder(['acmephp.com']); + $this->assertEquals('pending', $order->getStatus()); $challenges = $order->getAuthorizationChallenges('acmephp.com'); foreach ($challenges as $challenge) { if ('http-01' === $challenge->getType()) { @@ -100,6 +101,15 @@ public function testFullProcess(KeyOption $keyOption, bool $useAlternateCertific $this->cleanChallenge($challenge->getToken()); } + /** + * Reload order, check if challenge was completed. + */ + $updatedOrder = $client->reloadOrder($order); + $this->assertEquals('ready', $updatedOrder->getStatus()); + $this->assertCount(1, $updatedOrder->getAuthorizationChallenges('acmephp.com')); + $validatedChallenge = $updatedOrder->getAuthorizationChallenges('acmephp.com')[0]; + $this->assertEquals('valid', $validatedChallenge->getStatus()); + /* * Request certificate */ From 192a15cbc5be12572dcbdf435ddae74ffb96ded2 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Tue, 7 Jun 2022 22:41:57 +0200 Subject: [PATCH 14/77] Release of new version 2.1.0 --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcba8e10..213c3d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements +8a8a975 Merge pull request #263 from acmephp/core-get-order +95c17a4 Add Core\AcmeClient::reloadOrder method +7bac887 Merge pull request #257 from mgriego/core-deps-and-bug-fixes +371c905 Merge pull request #251 from W0rma/remove-swiftmailer +09e4bea Serialize embedded authorization challenges when serializing order objects. +d345ffe Allow for newer dependencies and fix a couple of issues in AcmePhp\Core. +8be2586 Merge pull request #262 from acmephp/upgrade-phpcs +03d14b3 Remove unused swiftmailer dependency +74b71f5 Merge pull request #254 from W0rma/fix-badges +182d539 Fix CS +2ae3edf Upgrade PHP-CS-Fixer +d685b93 Fix badges in README +c7fb74e Merge pull request #233 from tbickley-mediabowl/issue/197_Monolog2 +043fd6c Allow Monolog version 2 +e23b888 Merge pull request #261 from acmephp/php81 +2cfc866 Allow Symfony 6 +2755d98 Add PHP 8.1 tests and fix deprecations +22df0d1 feature #250 Fix tests on PHP 8.0/8.1 (HansAdema) +7621356 Fix tests on PHP 8.0/8.1 +2299602 Update README.md +2e43e83 Merge pull request #231 from piotrantosik/feature/core-deps +192872c Allow lcobucci/jwt ^4.0 in core package 03/02/2021 22:29 2.0.1 Fix requirements 8efc61a Fix CI config 8b26916 Merge pull request #223 from piotrantosik/patch-1 From 112f660d762e9c5c8694e9f3293e6ab0c13afdbe Mon Sep 17 00:00:00 2001 From: duobradovic <153935011+duobradovic@users.noreply.github.com> Date: Fri, 15 Dec 2023 17:45:35 +0100 Subject: [PATCH 15/77] Accept Json when expected --- src/Core/Http/SecureHttpClient.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Core/Http/SecureHttpClient.php b/src/Core/Http/SecureHttpClient.php index efcd7cd0..6fac9553 100644 --- a/src/Core/Http/SecureHttpClient.php +++ b/src/Core/Http/SecureHttpClient.php @@ -197,7 +197,7 @@ public function createExternalAccountPayload(ExternalAccount $externalAccount, s */ public function request(string $method, string $endpoint, array $data = [], bool $returnJson = true) { - $response = $this->rawRequest($method, $endpoint, $data); + $response = $this->rawRequest($method, $endpoint, $data, $returnJson); $body = Utils::copyToString($response->getBody()); if (!$returnJson) { @@ -224,10 +224,10 @@ public function request(string $method, string $endpoint, array $data = [], bool * @throws ExpectedJsonException when $returnJson = true and the response is not valid JSON * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code */ - public function rawRequest(string $method, string $endpoint, array $data = []): ResponseInterface + public function rawRequest(string $method, string $endpoint, array $data = [], bool $acceptJson = false): ResponseInterface { - $call = function () use ($method, $endpoint, $data) { - $request = $this->createRequest($method, $endpoint, $data); + $call = function () use ($method, $endpoint, $data, $acceptJson) { + $request = $this->createRequest($method, $endpoint, $data, $acceptJson); try { $this->lastResponse = $this->httpClient->send($request); } catch (\Exception $exception) { @@ -326,10 +326,15 @@ private function signPayload(array $protected, array $payload = null): array ]; } - private function createRequest($method, $endpoint, $data) + private function createRequest($method, $endpoint, $data, $acceptJson) { $request = new Request($method, $endpoint); - $request = $request->withHeader('Accept', 'application/json,application/jose+json,'); + + if ($acceptJson) { + $request = $request->withHeader('Accept', 'application/json,application/jose+json,'); + } else { + $request = $request->withHeader('Accept', '*/*'); + } if ('POST' === $method && \is_array($data)) { $request = $request->withHeader('Content-Type', 'application/jose+json'); From cb1a237821a6fd49c6ae090cf954f420433141ac Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Fri, 15 Mar 2024 16:11:21 +0100 Subject: [PATCH 16/77] fix: allow psr/http-message v2 --- src/Core/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/composer.json b/src/Core/composer.json index 2e82021a..7cb1e11f 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -35,7 +35,7 @@ "guzzlehttp/guzzle": "^6.0|^7.0", "guzzlehttp/psr7": "^1.7|^2.1", "lcobucci/jwt": "^3.3|^4.0", - "psr/http-message": "^1.0", + "psr/http-message": "^1 || ^2", "psr/log": "^1.0|^2.0|^3.0", "webmozart/assert": "^1.0" }, From 16c2e03e1ea8ab192cb06d820dc5af3d150d2288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20St=C3=B6ckl?= Date: Fri, 15 Mar 2024 17:46:42 +0100 Subject: [PATCH 17/77] Revert "fix: allow psr/http-message v2" --- src/Core/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/composer.json b/src/Core/composer.json index 7cb1e11f..2e82021a 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -35,7 +35,7 @@ "guzzlehttp/guzzle": "^6.0|^7.0", "guzzlehttp/psr7": "^1.7|^2.1", "lcobucci/jwt": "^3.3|^4.0", - "psr/http-message": "^1 || ^2", + "psr/http-message": "^1.0", "psr/log": "^1.0|^2.0|^3.0", "webmozart/assert": "^1.0" }, From aa4e614ec3833884c61c95c81fd58d3d76e9e6ea Mon Sep 17 00:00:00 2001 From: Harry Lewis Date: Fri, 12 Apr 2024 18:57:06 +0100 Subject: [PATCH 18/77] Add Tests\AcmePhp\Core\AcmeClientTest::testRequestAuthorizationAllowsCapitalisation() --- tests/Core/AcmeClientTest.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Core/AcmeClientTest.php b/tests/Core/AcmeClientTest.php index 1ba447c5..0838684c 100644 --- a/tests/Core/AcmeClientTest.php +++ b/tests/Core/AcmeClientTest.php @@ -131,4 +131,37 @@ public function testFullProcess(KeyOption $keyOption, bool $useAlternateCertific $this->assertStringContainsString('Unable to find specified certificate', $e->getPrevious()->getPrevious()->getMessage()); } } + + /** + * @dataProvider provideFullProcess + */ + public function testRequestAuthorizationAllowsCapitalisation(KeyOption $keyOption, bool $useAlternateCertificate) + { + $secureHttpClient = new SecureHttpClient( + (new KeyPairGenerator())->generateKeyPair($keyOption), + new Client(), + new Base64SafeEncoder(), + new KeyParser(), + new DataSigner(), + new ServerErrorHandler() + ); + + $client = new AcmeClient($secureHttpClient, 'https://localhost:14000/dir'); + + /* + * Register account + */ + if ('eab' === getenv('PEBBLE_MODE')) { + $client->registerAccount('titouan.galopin@acmephp.com', new ExternalAccount('kid1', 'dGVzdGluZw')); + } else { + $client->registerAccount('titouan.galopin@acmephp.com'); + } + + /* + * Request authorization challenges using a domain with capital letters + */ + $challenges = $client->requestAuthorization('ACMEPHP.com'); + + $this->assertNotEmpty($challenges); + } } From 9cd8f00d5ed6085b459c3bf1c74b5b49d88a9322 Mon Sep 17 00:00:00 2001 From: Harry Lewis Date: Fri, 12 Apr 2024 19:04:48 +0100 Subject: [PATCH 19/77] #280 Set domain name strings to lowercase in AcmeClient::requestOrder() and CertificateOrder::getAuthorizationChallenges() --- src/Core/AcmeClient.php | 2 +- src/Core/Protocol/CertificateOrder.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Core/AcmeClient.php b/src/Core/AcmeClient.php index 24a9fb31..8f7531aa 100644 --- a/src/Core/AcmeClient.php +++ b/src/Core/AcmeClient.php @@ -116,7 +116,7 @@ public function requestOrder(array $domains): CertificateOrder static function ($domain) { return [ 'type' => 'dns', - 'value' => $domain, + 'value' => strtolower($domain), ]; }, array_values($domains) diff --git a/src/Core/Protocol/CertificateOrder.php b/src/Core/Protocol/CertificateOrder.php index a78bd830..2f7e11ec 100644 --- a/src/Core/Protocol/CertificateOrder.php +++ b/src/Core/Protocol/CertificateOrder.php @@ -83,6 +83,8 @@ public function getAuthorizationsChallenges() */ public function getAuthorizationChallenges(string $domain): array { + $domain = strtolower($domain); + if (!isset($this->authorizationsChallenges[$domain])) { throw new AcmeCoreClientException('The order does not contains any authorization challenge for the domain '.$domain); } From c47222ebcacc0586f363b171d61d6686df3ac439 Mon Sep 17 00:00:00 2001 From: Harry Lewis Date: Mon, 15 Apr 2024 12:06:00 +0100 Subject: [PATCH 20/77] Chain previous into re-thrown exceptions --- src/Core/AcmeClient.php | 2 +- src/Core/Challenge/Dns/LibDnsResolver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/AcmeClient.php b/src/Core/AcmeClient.php index 8f7531aa..cae90bc6 100644 --- a/src/Core/AcmeClient.php +++ b/src/Core/AcmeClient.php @@ -226,7 +226,7 @@ public function requestAuthorization(string $domain): array try { return $order->getAuthorizationChallenges($domain); } catch (AcmeCoreClientException $e) { - throw new ChallengeNotSupportedException(); + throw new ChallengeNotSupportedException($e); } } diff --git a/src/Core/Challenge/Dns/LibDnsResolver.php b/src/Core/Challenge/Dns/LibDnsResolver.php index 5cce509b..3030da2e 100644 --- a/src/Core/Challenge/Dns/LibDnsResolver.php +++ b/src/Core/Challenge/Dns/LibDnsResolver.php @@ -97,7 +97,7 @@ public function getTxtEntries($domain): array try { $response = $this->request($domain, ResourceTypes::TXT, $ipNameServer[0]); } catch (\Exception $e) { - throw new AcmeDnsResolutionException(sprintf('Unable to find domain %s on nameserver %s', $domain, $nameServer)); + throw new AcmeDnsResolutionException(sprintf('Unable to find domain %s on nameserver %s', $domain, $nameServer), $e); } $entries = []; foreach ($response->getAnswerRecords() as $record) { From 54df0f8ba0d30b66aa352a27a5a4520588a3231d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 10:53:04 +0200 Subject: [PATCH 21/77] Fix CHANGELOG.md --- CHANGELOG.md | 537 +++++++++++++++++++++++++++------------------------ 1 file changed, 282 insertions(+), 255 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 213c3d73..3c875679 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,245 +1,269 @@ -07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements -8a8a975 Merge pull request #263 from acmephp/core-get-order -95c17a4 Add Core\AcmeClient::reloadOrder method -7bac887 Merge pull request #257 from mgriego/core-deps-and-bug-fixes -371c905 Merge pull request #251 from W0rma/remove-swiftmailer -09e4bea Serialize embedded authorization challenges when serializing order objects. -d345ffe Allow for newer dependencies and fix a couple of issues in AcmePhp\Core. -8be2586 Merge pull request #262 from acmephp/upgrade-phpcs -03d14b3 Remove unused swiftmailer dependency -74b71f5 Merge pull request #254 from W0rma/fix-badges -182d539 Fix CS -2ae3edf Upgrade PHP-CS-Fixer -d685b93 Fix badges in README -c7fb74e Merge pull request #233 from tbickley-mediabowl/issue/197_Monolog2 -043fd6c Allow Monolog version 2 -e23b888 Merge pull request #261 from acmephp/php81 -2cfc866 Allow Symfony 6 -2755d98 Add PHP 8.1 tests and fix deprecations -22df0d1 feature #250 Fix tests on PHP 8.0/8.1 (HansAdema) -7621356 Fix tests on PHP 8.0/8.1 -2299602 Update README.md -2e43e83 Merge pull request #231 from piotrantosik/feature/core-deps -192872c Allow lcobucci/jwt ^4.0 in core package -03/02/2021 22:29 2.0.1 Fix requirements -8efc61a Fix CI config -8b26916 Merge pull request #223 from piotrantosik/patch-1 -f836e0c Merge pull request #224 from jackdpeterson/expand_composer_deps -b50c730 expand compatibility range for lcobucci/jwt to include both ^3.3 as well as ^4.0. -f1fbaf1 Require acmephp/ssl 2.0 -14/12/2020 20:10 2.0.0 v2.0 -2683496 Fix Box config and bump version -4f56592 Merge pull request #212 from acmephp/2.0 -65a0ac1 Fix tests and CS -8dc7923 Add alternate certificate tests -258ea5c Add option that allows a client to download the alternate certificate link instead of the default one -7e96853 Fix encoding issue -e3550c5 Allow to configure directly EAB credentials -c2bf09b Finalize EAB support -8f10906 Adapt tests -12533ba Add EAB structure -7fa7a2a Add EAB test -701b864 Bump minimum version of Symfony -5183019 Remove legacy tests -5ef6681 Migrate to Github Actions -3fc8c60 Remove deprecated features -ccbba76 Fix CS -2a473a8 Migrate acmephp/cli to use typehints -7d6b566 Fix tests -ab68cac Bump PHP-CS-Fixer version -c061e3a Migrate acmephp/core to use typehints -b342a86 Migrate acmephp/ssl to use typehints -be0a5b1 Fix subpackages composer.json -e51784a Remove deprecated commands, improve tests on Run command and merge v2 interfaces -e2be9c3 Upgrade dependencies and drop support for PHP <7.2 -2330ef6 Bump version -13/12/2020 23:03 1.3.0 v1.3.0 -5d37fb1 Merge pull request #218 from acmephp/do-not-verify-https-http-vaidator -fe50cf6 Merge pull request #217 from acmephp/openssl-php8 -e849f30 Do not check HTTPS certificate validity in HttpValidator -38a9a5f Fix openssl_free_key deprecation notice in PHP 8 -cb1eae4 Merge pull request #219 from acmephp/fix-tests -5514e91 Fix 1.0 CI -db4d497 Merge pull request #192 from acmephp/handle-processing -965c6b6 Fix Box config for latest Box version -6968927 Merge pull request #208 from InfinityFreeHosting/guzzle-7 -6ec9c47 Support both Guzzle 6.x and 7.x -9565469 Merge pull request #204 from p-seven-v/add-rejected-identifier-exception -a9ed8ac Fixed quotes -c0d3f0d Added more exceptions -3749f96 Reordered alphabetically -47c2139 Added class comment -765dd86 Added RejectedIdentifierServerException -852d90c Handle processing status case -5b07014 Merge pull request #193 from acmephp/update-ci -6133be4 Fix coding-style -252306a Update CI configuration -312ef14 Merge pull request #190 from philipsharp/response-body-summary -187ce72 Merge pull request #188 from miranovy/master -edcb011 Rewind response body before generating summary for server errors -a156f98 Distinguished name assert update -15/01/2020 22:42 1.2.0 Release version 1.2.0 -d031223 Merge pull request #185 from miranovy/master -24b8575 Fix getIssuerCertificate return type -df8f156 Merge pull request #183 from jderusse/split-request -b86d2d6 Merge pull request #184 from miranovy/master -ec1bbba fix the wrong return type -028470a fix the wrong return type -25a12e3 Split Sign and Request -937a2f7 Merge pull request #182 from pauladams8/master -c592b85 added orderNotReady error type -0d09084 Merge pull request #180 from jderusse/fix-test -f0e9422 Add php 7.3 and 7.4 -6b65f1a Merge pull request #164 from trustocean/feat-install-aliyun-cdn -d060f0c style ci, no spacing near dot -222f184 重名时阿里云会报错 -51da67e Merge branch 'master' of https://github.com/acmephp/acmephp into feat-install-aliyun-cdn -9203dec Merge pull request #163 from trustocean/feat-install-aliyun-waf -ce4bb92 style ci -45037e1 Merge branch 'master' of https://github.com/acmephp/acmephp into feat-install-aliyun-cdn -dcd1ad7 fixbug -bce7829 fixbug -3292b41 fix -2400302 remove wrong conf -0501e56 register in services -505d4c2 stash -0d522f7 Update InstallAliyunWafAction.php -91049e3 Remove try...catch wrapper -e9fefc3 stash -2d88030 Merge pull request #161 from jderusse/deprecate-commands -723de09 style ci -1a17f6e fix style ci -40558ea close #17 -05a2f39 fix -8541342 statsh -d865632 Merge pull request #162 from aik099/gandi-dns-solver-feat -83e47d3 Removed unused code -62d9b1b CS fixes -9eeb20a Adding Gandi.Net DNS solver class -8bae348 Deprecate commands in favor of run -9ef2916 Merge pull request #153 from elliotfehr/missed-memleak -c1271c0 free openssl resource after reading -b276743 Merge pull request #151 from elliotfehr/openssl-mem-leak -1effe3e Merge branch 'master' into openssl-mem-leak -58ee1e6 Merge pull request #152 from jderusse/fix-cs -2071f9d Fix CS -bb55db6 free the key resource after reading +# CHANGELOG + +## 3.0.0 (not released yet) + +> [!NOTE] +> From now on, a particular attention will be given to provide a nice changelog. + +## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements + +* 8a8a975 Merge pull request #263 from acmephp/core-get-order +* 95c17a4 Add Core\AcmeClient::reloadOrder method +* 7bac887 Merge pull request #257 from mgriego/core-deps-and-bug-fixes +* 371c905 Merge pull request #251 from W0rma/remove-swiftmailer +* 09e4bea Serialize embedded authorization challenges when serializing order objects. +* d345ffe Allow for newer dependencies and fix a couple of issues in AcmePhp\Core. +* 8be2586 Merge pull request #262 from acmephp/upgrade-phpcs +* 03d14b3 Remove unused swiftmailer dependency +* 74b71f5 Merge pull request #254 from W0rma/fix-badges +* 182d539 Fix CS +* 2ae3edf Upgrade PHP-CS-Fixer +* d685b93 Fix badges in README +* c7fb74e Merge pull request #233 from tbickley-mediabowl/issue/197_Monolog2 +* 043fd6c Allow Monolog version 2 +* e23b888 Merge pull request #261 from acmephp/php81 +* 2cfc866 Allow Symfony 6 +* 2755d98 Add PHP 8.1 tests and fix deprecations +* 22df0d1 feature #250 Fix tests on PHP 8.0/8.1 (HansAdema) +* 7621356 Fix tests on PHP 8.0/8.1 +* 2299602 Update README.md +* 2e43e83 Merge pull request #231 from piotrantosik/feature/core-deps +* 192872c Allow lcobucci/jwt ^4.0 in core package + +## 03/02/2021 22:29 2.0.1 Fix requirements + +* 8efc61a Fix CI config +* 8b26916 Merge pull request #223 from piotrantosik/patch-1 +* f836e0c Merge pull request #224 from jackdpeterson/expand_composer_deps +* b50c730 expand compatibility range for lcobucci/jwt to include both ^3.3 as well as ^4.0. +* f1fbaf1 Require acmephp/ssl 2.0 + +## 14/12/2020 20:10 2.0.0 v2.0 + +* 2683496 Fix Box config and bump version +* 4f56592 Merge pull request #212 from acmephp/2.0 +* 65a0ac1 Fix tests and CS +* 8dc7923 Add alternate certificate tests +258ea5c Add option that allows a client to download the alternate certificate link instead * of the default one +* 7e96853 Fix encoding issue +* e3550c5 Allow to configure directly EAB credentials +* c2bf09b Finalize EAB support +* 8f10906 Adapt tests +* 12533ba Add EAB structure +* 7fa7a2a Add EAB test +* 701b864 Bump minimum version of Symfony +* 5183019 Remove legacy tests +* 5ef6681 Migrate to Github Actions +* 3fc8c60 Remove deprecated features +* ccbba76 Fix CS +* 2a473a8 Migrate acmephp/cli to use typehints +* 7d6b566 Fix tests +* ab68cac Bump PHP-CS-Fixer version +* c061e3a Migrate acmephp/core to use typehints +* b342a86 Migrate acmephp/ssl to use typehints +* be0a5b1 Fix subpackages composer.json +* e51784a Remove deprecated commands, improve tests on Run command and merge v2 interfaces +* e2be9c3 Upgrade dependencies and drop support for PHP <7.2 +* 2330ef6 Bump version + +## 13/12/2020 23:03 1.3.0 v1.3.0 + +* 5d37fb1 Merge pull request #218 from acmephp/do-not-verify-https-http-vaidator +* fe50cf6 Merge pull request #217 from acmephp/openssl-php8 +* e849f30 Do not check HTTPS certificate validity in HttpValidator +* 38a9a5f Fix openssl_free_key deprecation notice in PHP 8 +* cb1eae4 Merge pull request #219 from acmephp/fix-tests +* 5514e91 Fix 1.0 CI +* db4d497 Merge pull request #192 from acmephp/handle-processing +* 965c6b6 Fix Box config for latest Box version +* 6968927 Merge pull request #208 from InfinityFreeHosting/guzzle-7 +* 6ec9c47 Support both Guzzle 6.x and 7.x +* 9565469 Merge pull request #204 from p-seven-v/add-rejected-identifier-exception +* a9ed8ac Fixed quotes +* c0d3f0d Added more exceptions +* 3749f96 Reordered alphabetically +* 47c2139 Added class comment +* 765dd86 Added RejectedIdentifierServerException +* 852d90c Handle processing status case +* 5b07014 Merge pull request #193 from acmephp/update-ci +* 6133be4 Fix coding-style +* 252306a Update CI configuration +* 312ef14 Merge pull request #190 from philipsharp/response-body-summary +* 187ce72 Merge pull request #188 from miranovy/master +* edcb011 Rewind response body before generating summary for server errors +* a156f98 Distinguished name assert update + +## 15/01/2020 22:42 1.2.0 Release version 1.2.0 + +* d031223 Merge pull request #185 from miranovy/master +* 24b8575 Fix getIssuerCertificate return type +* df8f156 Merge pull request #183 from jderusse/split-request +* b86d2d6 Merge pull request #184 from miranovy/master +* ec1bbba fix the wrong return type +* 028470a fix the wrong return type +* 25a12e3 Split Sign and Request +* 937a2f7 Merge pull request #182 from pauladams8/master +* c592b85 added orderNotReady error type +* 0d09084 Merge pull request #180 from jderusse/fix-test +* f0e9422 Add php 7.3 and 7.4 +* 6b65f1a Merge pull request #164 from trustocean/feat-install-aliyun-cdn +* d060f0c style ci, no spacing near dot +* 222f184 重名时阿里云会报错 +51da67e Merge branch 'master' of https://github.com/acmephp/acmephp into * feat-install-aliyun-cdn +* 9203dec Merge pull request #163 from trustocean/feat-install-aliyun-waf +* ce4bb92 style ci +45037e1 Merge branch 'master' of https://github.com/acmephp/acmephp into * feat-install-aliyun-cdn +* dcd1ad7 fixbug +* bce7829 fixbug +* 3292b41 fix +* 2400302 remove wrong conf +* 0501e56 register in services +* 505d4c2 stash +* 0d522f7 Update InstallAliyunWafAction.php +* 91049e3 Remove try...catch wrapper +* e9fefc3 stash +* 2d88030 Merge pull request #161 from jderusse/deprecate-commands +* 723de09 style ci +* 1a17f6e fix style ci +* 40558ea close #17 +* 05a2f39 fix +* 8541342 statsh +* d865632 Merge pull request #162 from aik099/gandi-dns-solver-feat +* 83e47d3 Removed unused code +* 62d9b1b CS fixes +* 9eeb20a Adding Gandi.Net DNS solver class +* 8bae348 Deprecate commands in favor of run +* 9ef2916 Merge pull request #153 from elliotfehr/missed-memleak +* c1271c0 free openssl resource after reading +* b276743 Merge pull request #151 from elliotfehr/openssl-mem-leak +* 1effe3e Merge branch 'master' into openssl-mem-leak +* 58ee1e6 Merge pull request #152 from jderusse/fix-cs +* 2071f9d Fix CS +* bb55db6 free the key resource after reading 8c9d313 Build 1.1.1 PHAR -18/01/2019 15:17 1.1.1 Several bug fixes -952b1a6 Merge pull request #148 from rokclimb15/patch-1 -56df417 Correctly throw ChallengeTimedOutException -c7f523f Merge pull request #145 from jderusse/fix-exceptionx -034b6a2 Fix exception constructor -ff10617 Merge pull request #146 from jderusse/fix-deprec -9e754ad Fix 4.2 deprecations -10/11/2018 12:55 1.1.0 Add support for certificate revocation and ECDSA certificates -6933ffb Merge pull request #141 from jderusse/ecdsa -f7bac9e Fix undefined const OPENSSL_KEYTYPE_EC -5cf1a8d Add DH and DSA generators -c22cd9e Add support for ECDSA -3881f18 Merge pull request #143 from jderusse/update-phpunit -2cf3baf Use simple-phpunit to run tests -5194897 Merge pull request #142 from jderusse/fix-deps -4f13320 Add missing dependencies in composer.json files -da7c0e1 Merge pull request #139 from acmephp/revoke-certificate -39cf7fa Fix certificate revocation -27d4355 Update test to pass with Pebble implementation -94e2f20 Remove Certificate::__toString(), Command validation failure warning -> error -ef00e5f Add revocation reason and more helpful doc -c61019c Fix cs issues -7418bd9 Add api for certificate revocation -6d3888e Merge pull request #140 from acmephp/remove-scrutinizer -29258e6 Remove Scrutinizer -61df472 Merge pull request #138 from acmephp/remove-config-platform -af56ed7 Remove config.platform.php in Composer -e8029c2 Bump to dev -27/10/2018 12:07 1.0.1 Fix PHP version issue -6079833 Merge pull request #137 from acmephp/fix-php-version -6d6e2d2 Fix tests configuration -12ed5fc Fix PHP version in composer.json -958d497 Remove Gitter -a4effb8 Add link to core and ssl libraries in README -b17236e Bump to dev -14/10/2018 12:05 1.0.0 First stable release -1e4ba50 Merge pull request #135 from acmephp/prepare-release -13866eb Update README -9d773bb Remove beta messages -25e986e Prepare stable release, use only PrettyCI and fix CS -6267095 Merge pull request #134 from ScullWM/patch-1 -542ed28 Fix markdown error -c90e0a8 Merge pull request #132 from jderusse/optimize-route53 -c6b767a Optimize Route53 resolution -d4d2fa6 Merge pull request #131 from jderusse/catch-unresolvabled-nameserver -d57be04 Merge pull request #130 from alexmckinnon/csr-payload -1fd6427 Add common name to CSR payload -95f30c4 atch case where NameServer is not resolvable -421a4ab Merge pull request #128 from jderusse/update-dependencies -cdde24e Update dependencies -9b8ae4c Merge pull request #127 from jderusse/improve-libdns-fetching -d553270 Improve DNS checking -93bf725 Merge pull request #126 from jderusse/catch-libdns-exception-2 -c40f93b Catch exception on external calls -9bdd3ed Merge pull request #125 from jderusse/catch-libdns-exception -1930de5 Wrap external call in try/catch block -03b5532 Merge pull request #123 from jderusse/fix-status -c2b6b8d Allow "ready" status for orders with valid challenges -f039226 Merge pull request #119 from acmephp/auto-split -9ea70bc Automate split -32ccf3f Merge pull request #120 from jderusse/refactor-travis -2b5b296 Add comments -9b7ea2b Switch to travis pipeline -bbe4b9b Merge pull request #116 from jderusse/fix-sftp-config -db6c434 Merge pull request #115 from jderusse/fix-missing-lib -db391fc Add lib-xml used by SFTP adapter -922bd70 Fix typo in config -4a08ccc Merge pull request #113 from jderusse/fix-route53-domain-lookupx -bce7338 Fix Route53 zone search -c08891c Merge pull request #109 from jderusse/optimize-resolve -5dddf23 Optimize Route53 solvin -166dde3 Merge pull request #112 from kirtangajjar/fix-nginxproxy-wildcard -a848329 Merge pull request #111 from kirtangajjar/fix-nginxproxy-crt-generation -01f00c8 Merge pull request #107 from jderusse/feature-improve-error-messages -34bd808 Merge pull request #108 from jderusse/fix-payload -ca6531f Fix nginxproxy wildcard certificates -bac8140 Fixed in a bit better way -d081953 Fix nginxproxy crt generation -09ff221 Remove non linear index on array -26e672a Improve error messages -74dd66d Merge pull request #104 from benjilevens/laravel-5.5 -55d7b9b Merge pull request #106 from benjilevens/jose-json -2dd3303 Merge pull request #102 from jderusse/feature-skip-challenge -d4dcd9f Merge pull request #105 from benjilevens/request-certificate-calling-finalize-order -503c4df Use more appropriate Accept and Content-Type headers -475f359 Support multiple versions of swift mailer -4b9dac7 Make requestCertificate call finalizeOrder with required parameters -005081d Bump Swiftmailer version to prevent composer conflicts when installing into a Laravel 5.5 project -82e5e5b Skip challenge when no renewal -fd54a08 Merge pull request #101 from jderusse/feature-multiple-challenges -dd88adc Optimize challenge solving by solving several challenges at once -0e618e3 Merge pull request #100 from jderusse/feature-file-solver -898c939 Use service locator -04c9814 Add a filesystem solver (to upload http challenge) -9818d39 Merge pull request #98 from jderusse/fix-tree -208913f Refactor file tree -4966d60 Merge pull request #96 from jderusse/fix-combined-public -1671a5b Merge pull request #97 from jderusse/fix-status-expired -e327321 Add an option to hide/show expired certificates -51ebab0 Move combined certificate in private folder -bd1478e Merge pull request #95 from jderusse/fix-ci -a08cb2e Fix CS -1d590bb Switch from styleCi to travis -477929d Merge pull request #94 from jderusse/fix-debug -75552fd Remove debug -c4b8c66 Merge pull request #87 from jderusse/feature/run -38e49cb Add a run command -15c1809 Merge pull request #93 from jderusse/feature/docker -9907669 Add a dockerfile -a7b8581 Merge pull request #92 from jderusse/v2 -1550972 Implement v2 protocol -6d15380 Implement ELB installation -3c8b06a Add Route53 solver -f306733 Bump to dev -21/01/2018 18:31 1.0.0-beta5 Fix deprecations and allow setting KeyPair from Client object + +## 18/01/2019 15:17 1.1.1 Several bug fixes + +* 952b1a6 Merge pull request #148 from rokclimb15/patch-1 +* 56df417 Correctly throw ChallengeTimedOutException +* c7f523f Merge pull request #145 from jderusse/fix-exceptionx +* 034b6a2 Fix exception constructor +* ff10617 Merge pull request #146 from jderusse/fix-deprec +* 9e754ad Fix 4.2 deprecations +* 10/11/2018 12:55 1.1.0 Add support for certificate revocation and ECDSA certificates +* 6933ffb Merge pull request #141 from jderusse/ecdsa +* f7bac9e Fix undefined const OPENSSL_KEYTYPE_EC +* 5cf1a8d Add DH and DSA generators +* c22cd9e Add support for ECDSA +* 3881f18 Merge pull request #143 from jderusse/update-phpunit +* 2cf3baf Use simple-phpunit to run tests +* 5194897 Merge pull request #142 from jderusse/fix-deps +* 4f13320 Add missing dependencies in composer.json files +* da7c0e1 Merge pull request #139 from acmephp/revoke-certificate +* 39cf7fa Fix certificate revocation +* 27d4355 Update test to pass with Pebble implementation +* 94e2f20 Remove Certificate::__toString(), Command validation failure warning -> error +* ef00e5f Add revocation reason and more helpful doc +* c61019c Fix cs issues +* 7418bd9 Add api for certificate revocation +* 6d3888e Merge pull request #140 from acmephp/remove-scrutinizer +* 29258e6 Remove Scrutinizer +* 61df472 Merge pull request #138 from acmephp/remove-config-platform +* af56ed7 Remove config.platform.php in Composer +* e8029c2 Bump to dev + +## 27/10/2018 12:07 1.0.1 Fix PHP version issue + +* 6079833 Merge pull request #137 from acmephp/fix-php-version +* 6d6e2d2 Fix tests configuration +* 12ed5fc Fix PHP version in composer.json +* 958d497 Remove Gitter +* a4effb8 Add link to core and ssl libraries in README +* b17236e Bump to dev + +## 14/10/2018 12:05 1.0.0 First stable release + +* 1e4ba50 Merge pull request #135 from acmephp/prepare-release +* 13866eb Update README +* 9d773bb Remove beta messages +* 25e986e Prepare stable release, use only PrettyCI and fix CS +* 6267095 Merge pull request #134 from ScullWM/patch-1 +* 542ed28 Fix markdown error +* c90e0a8 Merge pull request #132 from jderusse/optimize-route53 +* c6b767a Optimize Route53 resolution +* d4d2fa6 Merge pull request #131 from jderusse/catch-unresolvabled-nameserver +* d57be04 Merge pull request #130 from alexmckinnon/csr-payload +* 1fd6427 Add common name to CSR payload +* 95f30c4 atch case where NameServer is not resolvable +* 421a4ab Merge pull request #128 from jderusse/update-dependencies +* cdde24e Update dependencies +* 9b8ae4c Merge pull request #127 from jderusse/improve-libdns-fetching +* d553270 Improve DNS checking +* 93bf725 Merge pull request #126 from jderusse/catch-libdns-exception-2 +* c40f93b Catch exception on external calls +* 9bdd3ed Merge pull request #125 from jderusse/catch-libdns-exception +* 1930de5 Wrap external call in try/catch block +* 03b5532 Merge pull request #123 from jderusse/fix-status +* c2b6b8d Allow "ready" status for orders with valid challenges +* f039226 Merge pull request #119 from acmephp/auto-split +* 9ea70bc Automate split +* 32ccf3f Merge pull request #120 from jderusse/refactor-travis +* 2b5b296 Add comments +* 9b7ea2b Switch to travis pipeline +* bbe4b9b Merge pull request #116 from jderusse/fix-sftp-config +* db6c434 Merge pull request #115 from jderusse/fix-missing-lib +* db391fc Add lib-xml used by SFTP adapter +* 922bd70 Fix typo in config +* 4a08ccc Merge pull request #113 from jderusse/fix-route53-domain-lookupx +* bce7338 Fix Route53 zone search +* c08891c Merge pull request #109 from jderusse/optimize-resolve +* 5dddf23 Optimize Route53 solvin +* 166dde3 Merge pull request #112 from kirtangajjar/fix-nginxproxy-wildcard +* a848329 Merge pull request #111 from kirtangajjar/fix-nginxproxy-crt-generation +* 01f00c8 Merge pull request #107 from jderusse/feature-improve-error-messages +* 34bd808 Merge pull request #108 from jderusse/fix-payload +* ca6531f Fix nginxproxy wildcard certificates +* bac8140 Fixed in a bit better way +* d081953 Fix nginxproxy crt generation +* 09ff221 Remove non linear index on array +* 26e672a Improve error messages +* 74dd66d Merge pull request #104 from benjilevens/laravel-5.5 +* 55d7b9b Merge pull request #106 from benjilevens/jose-json +* 2dd3303 Merge pull request #102 from jderusse/feature-skip-challenge +* d4dcd9f Merge pull request #105 from benjilevens/request-certificate-calling-finalize-order +* 503c4df Use more appropriate Accept and Content-Type headers +* 475f359 Support multiple versions of swift mailer +* 4b9dac7 Make requestCertificate call finalizeOrder with required parameters +005081d Bump Swiftmailer version to prevent composer conflicts when installing into a * Laravel 5.5 project +* 82e5e5b Skip challenge when no renewal +* fd54a08 Merge pull request #101 from jderusse/feature-multiple-challenges +* dd88adc Optimize challenge solving by solving several challenges at once +* 0e618e3 Merge pull request #100 from jderusse/feature-file-solver +* 898c939 Use service locator +* 04c9814 Add a filesystem solver (to upload http challenge) +* 9818d39 Merge pull request #98 from jderusse/fix-tree +* 208913f Refactor file tree +* 4966d60 Merge pull request #96 from jderusse/fix-combined-public +* 1671a5b Merge pull request #97 from jderusse/fix-status-expired +* e327321 Add an option to hide/show expired certificates +* 51ebab0 Move combined certificate in private folder +* bd1478e Merge pull request #95 from jderusse/fix-ci +* a08cb2e Fix CS +* 1d590bb Switch from styleCi to travis +* 477929d Merge pull request #94 from jderusse/fix-debug +* 75552fd Remove debug +* c4b8c66 Merge pull request #87 from jderusse/feature/run +* 38e49cb Add a run command +* 15c1809 Merge pull request #93 from jderusse/feature/docker +* 9907669 Add a dockerfile +* a7b8581 Merge pull request #92 from jderusse/v2 +* 1550972 Implement v2 protocol +* 6d15380 Implement ELB installation +* 3c8b06a Add Route53 solver +* f306733 Bump to dev + +## 21/01/2018 18:31 1.0.0-beta5 Fix deprecations and allow setting KeyPair from Client object + 466e009 Release of new version 1.0.0-beta5 0a94b15 Fix mailer handler 8fde026 Allow setting KeyPair from Client object (#72) @@ -247,14 +271,17 @@ e2ac2bf Fix json_decode error handling in SecureHttpClient and ServerErrorHandle 4c7d10d Fix deprecations and improve tests f559a93 [doc] Fix typo on README 0b4ea8b Bump to dev -21/01/2018 18:23 1.0.0-beta5 Fix deprecations and allow setting KeyPair from Client object -0a94b15 Fix mailer handler -8fde026 Allow setting KeyPair from Client object (#72) -e2ac2bf Fix json_decode error handling in SecureHttpClient and ServerErrorHandler -4c7d10d Fix deprecations and improve tests -f559a93 [doc] Fix typo on README -0b4ea8b Bump to dev -* 1.0.0-beta4 (2017-01-29) + +## 21/01/2018 18:23 1.0.0-beta5 Fix deprecations and allow setting KeyPair from Client object + +* 0a94b15 Fix mailer handler +* 8fde026 Allow setting KeyPair from Client object (#72) +* e2ac2bf Fix json_decode error handling in SecureHttpClient and ServerErrorHandler +* 4c7d10d Fix deprecations and improve tests +* f559a93 [doc] Fix typo on README +* 0b4ea8b Bump to dev + +## 1.0.0-beta4 (2017-01-29) * 0b18a86 Redone nameing of ::getResource with new tests (#61) * 78d0e2d Accept empty issuer CN field (#59) @@ -272,7 +299,7 @@ f559a93 [doc] Fix typo on README * a7f194a Fix vendor/bin/acme autoload path * 5e4a887 Bump to dev -* 1.0.0-beta3 (2016-12-09) +## 1.0.0-beta3 (2016-12-09) * daa6d1c Merge pull request #40 from acmephp/fix-39 * 0b8629e Remove RECOVER_REGISTRATION obsolete unused resource @@ -284,7 +311,7 @@ f559a93 [doc] Fix typo on README * 794f8d5 Introduce CLI logger to handle different verbosities properly * e055695 Bump to dev -* 1.0.0-beta2 (2016-10-19) +## 1.0.0-beta2 (2016-10-19) * ed2cc9e Update main and components README files * 1adff0d Improve some commands descriptions @@ -306,7 +333,7 @@ f559a93 [doc] Fix typo on README * 1d1bf00 Rename challenger into SOlver * e1289df Allow custom challenger extension -* 1.0.0-beta1 (2016-09-24) +## 1.0.0-beta1 (2016-09-24) * f1585a4 Fix type in README * 54d68c3 Merge pull request #24 from jderusse/multi-domains @@ -317,12 +344,12 @@ f559a93 [doc] Fix typo on README * f7de82d Automatically agreed with agrement (#26) * 7accf30 Fix tests (#27) -* 1.0.0-alpha10 (2016-08-16) +## 1.0.0-alpha10 (2016-08-16) * 3bfa96c Update RegisterCommand.php (#21) * d3d779f Bump version -* 1.0.0-alpha9 (2016-07-27) +## 1.0.0-alpha9 (2016-07-27) * 3e89b38 Remove unsupported actions from the dist file for the moment * 07857e6 Add PHP 7.1 in Travis and improve CI configuration (#19) @@ -330,4 +357,4 @@ f559a93 [doc] Fix typo on README * adf4dc8 Update version as DEV * f61df6f Fix Guzzle URI test (#17) * 846bbce Fix assertions messages - * 113b2d8 Fix 404 on documentation link (#15) \ No newline at end of file + * 113b2d8 Fix 404 on documentation link (#15) From 3281eb12b84a1837ce45a4ddf628c94b79720d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 10:55:31 +0200 Subject: [PATCH 22/77] Remove '.rmt.yml' This tools generates totally useless changelog, and urgly! --- .rmt.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .rmt.yml diff --git a/.rmt.yml b/.rmt.yml deleted file mode 100644 index 6a18a5f0..00000000 --- a/.rmt.yml +++ /dev/null @@ -1,23 +0,0 @@ -vcs: - name: git - sign-tag: true - -version-generator: - name: semantic - allow-label: true - -version-persister: vcs-tag - -prerequisites: - display-last-changes: ~ - -pre-release-actions: - changelog-update: - format: simple - file: CHANGELOG.md - dump-commits: true - vcs-commit: ~ - -post-release-actions: - vcs-publish: - ask-confirmation: true From 9ec2ae2a954397ba9ceb0adeab8da5f0ea2bac1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 11:00:07 +0200 Subject: [PATCH 23/77] Make more robust setup.sh --- tests/setup.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index 18b3cb56..7165af64 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -1,17 +1,19 @@ #!/usr/bin/env bash +set -e +set -o pipefail + # Root directory -cd $( dirname "${BASH_SOURCE[0]}" ) -cd .. +cd $( dirname "${BASH_SOURCE[0]}" )/.. # SFTP -docker run -d --name acme_sftp -p 8022:22 atmoz/sftp acmephp:acmephp:::share +docker run -d --rm --name acme_sftp -p 8022:22 atmoz/sftp acmephp:acmephp:::share # pebble MODE=${PEBBLE_MODE:-default} -docker run -d --name acme_server --net host letsencrypt/pebble-challtestsrv pebble-challtestsrv -defaultIPv6 "" -defaultIPv4 127.0.0.1 -docker run -d --name acme_pebble --net host -e PEBBLE_VA_NOSLEEP=1 -e PEBBLE_WFE_NONCEREJECT=0 -e PEBBLE_ALTERNATE_ROOTS=1 -v $(pwd)/tests/Fixtures/pebble-config-$MODE.json:/test/config/pebble-config.json letsencrypt/pebble pebble -dnsserver 127.0.0.1:8053 +docker run -d --rm --name acme_server --net host letsencrypt/pebble-challtestsrv pebble-challtestsrv -defaultIPv6 "" -defaultIPv4 127.0.0.1 +docker run -d --rm --name acme_pebble --net host -e PEBBLE_VA_NOSLEEP=1 -e PEBBLE_WFE_NONCEREJECT=0 -e PEBBLE_ALTERNATE_ROOTS=1 -v $(pwd)/tests/Fixtures/pebble-config-$MODE.json:/test/config/pebble-config.json letsencrypt/pebble pebble -dnsserver 127.0.0.1:8053 # Wait for boot to be completed docker run --rm --net host martin/wait -c localhost:14000,localhost:8022,localhost:8053,localhost:5002 -t 120 From c1bc9e492df2c8998608fe6405863a6c4ffe92d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 11:02:58 +0200 Subject: [PATCH 24/77] Make more robust test.sh --- tests/run.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index d2c3ed8a..a5f3a4b5 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash +set -e +set -o pipefail + # Root directory -cd $( dirname "${BASH_SOURCE[0]}" ) -cd .. +cd $( dirname "${BASH_SOURCE[0]}" )/.. tempfile=$(mktemp) cert='-----BEGIN CERTIFICATE----- From f8b329365e804ec9b578f9f54fd6742947574f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 11:28:33 +0200 Subject: [PATCH 25/77] Drop support for outdated version (SF, PHP) and fix tests --- .github/workflows/test-build.yaml | 125 +++--------------- CHANGELOG.md | 3 + composer.json | 25 ++-- phpunit.xml.dist | 1 + src/Cli/Serializer/PemNormalizer.php | 8 ++ tests/Cli/Action/InstallAwsElbActionTest.php | 3 + .../Cli/Action/InstallAwsElbv2ActionTest.php | 3 + tests/Cli/Repository/RepositoryTest.php | 3 +- tests/Core/Challenge/ChainValidatorTest.php | 3 + .../Challenge/Dns/DnsDataExtractorTest.php | 3 + tests/Core/Challenge/Dns/DnsValidatorTest.php | 3 + tests/Core/Challenge/Dns/GandiSolverTest.php | 3 + .../Core/Challenge/Dns/Route53SolverTest.php | 3 + .../Challenge/Dns/SimpleDnsSolverTest.php | 3 + .../Challenge/Http/FilesystemSolverTest.php | 3 + .../Challenge/Http/HttpDataExtractorTest.php | 3 + .../Core/Challenge/Http/HttpValidatorTest.php | 3 + .../Challenge/Http/SimpleHttpSolverTest.php | 3 + tests/Core/Challenge/WaitingValidatorTest.php | 3 + 19 files changed, 80 insertions(+), 124 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index a3af626f..9adfb417 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -23,123 +23,30 @@ jobs: - name: Check coding style run: php php-cs-fixer.phar fix --dry-run --diff - tests-php72-sf50-low: + ci: + name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest - env: - SYMFONY_VERSION: 5.0.* - steps: - - uses: shivammathur/setup-php@v2 - with: - php-version: '7.2' - coverage: none - - - uses: actions/checkout@master - - - name: Install dependencies - run: | - composer require --dev "sebastian/comparator:^2.0" - composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION - composer require --no-update --dev symfony/finder=$SYMFONY_VERSION - composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable - - - name: Preparing tests - run: ./tests/setup.sh - - - name: Running tests - run: ./tests/run.sh - - tests-php73-sf54-low: - runs-on: ubuntu-latest - env: - SYMFONY_VERSION: 5.4.* - steps: - - uses: shivammathur/setup-php@v2 - with: - php-version: '7.3' - coverage: none - - - uses: actions/checkout@master - - - name: Install dependencies - run: | - composer require --dev "sebastian/comparator:^2.0" - composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION - composer require --no-update --dev symfony/finder=$SYMFONY_VERSION - composer update --no-interaction --no-progress --ansi --prefer-lowest --prefer-stable - - - name: Preparing tests - run: ./tests/setup.sh - - - name: Running tests - run: ./tests/run.sh - - tests-php74-sf54-high-eab: - runs-on: ubuntu-latest - env: - SYMFONY_VERSION: 5.4.* - PEBBLE_MODE: eab - steps: - - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - - - uses: actions/checkout@master + strategy: + fail-fast: false + matrix: + php-version: ["8.2", "8.3"] + composer-flags: [""] + name: [""] + include: + - php-version: 8.1 + composer-flags: "--prefer-lowest" + name: "(prefer lowest dependencies)" - - name: Install dependencies - run: | - composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION - composer require --no-update --dev symfony/finder=$SYMFONY_VERSION - composer update --no-interaction --no-progress --ansi --prefer-stable - - - name: Preparing tests - run: ./tests/setup.sh - - - name: Running tests - run: ./tests/run.sh - - tests-php80-sf60-high: - runs-on: ubuntu-latest - env: - SYMFONY_VERSION: 6.0.* steps: - uses: shivammathur/setup-php@v2 with: - php-version: '8.0' - coverage: none - - - uses: actions/checkout@master + php-version: ${{ matrix.php-version }} - - name: Install dependencies - run: | - composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION - composer require --no-update --dev symfony/finder=$SYMFONY_VERSION - composer update --no-interaction --no-progress --ansi --prefer-stable - - - name: Preparing tests - run: ./tests/setup.sh - - - name: Running tests - run: ./tests/run.sh - - tests-php81-sf61-high-eab: - runs-on: ubuntu-latest - env: - SYMFONY_VERSION: 6.1.* - PEBBLE_MODE: eab - steps: - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - coverage: none - - - uses: actions/checkout@master + - uses: actions/checkout@v4 - - name: Install dependencies + - name: Install Composer dependencies run: | - composer require --no-update symfony/config=$SYMFONY_VERSION symfony/console=$SYMFONY_VERSION symfony/dependency-injection=$SYMFONY_VERSION symfony/filesystem=$SYMFONY_VERSION symfony/serializer=$SYMFONY_VERSION symfony/yaml=$SYMFONY_VERSION - composer require --no-update --dev symfony/finder=$SYMFONY_VERSION - composer update --no-interaction --no-progress --ansi --prefer-stable + composer update --prefer-dist --no-interaction ${{ matrix.composer-flags }} - name: Preparing tests run: ./tests/setup.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c875679..ed010da4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ > [!NOTE] > From now on, a particular attention will be given to provide a nice changelog. +* Drop support for PHP <8.1 +* Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 + ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements * 8a8a975 Merge pull request #263 from acmephp/core-get-order diff --git a/composer.json b/composer.json index a358b3c8..6bb0b415 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ } ], "require": { - "php": ">=7.2.5", + "php": ">=8.1", "ext-filter": "*", "ext-hash": "*", "ext-json": "*", @@ -55,23 +55,20 @@ "psr/container": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0", - "symfony/config": "^5.0|^6.0", - "symfony/console": "^5.0|^6.0", - "symfony/dependency-injection": "^5.0|^6.0", - "symfony/filesystem": "^5.0|^6.0", - "symfony/serializer": "^5.0|^6.0", - "symfony/yaml": "^5.0|^6.0", + "symfony/config": "^5.4 || ^6.4", + "symfony/console": "^5.4 || ^6.4", + "symfony/dependency-injection": "^5.4 || ^6.4", + "symfony/filesystem": "^5.4 || ^6.4", + "symfony/serializer": "^5.4 || ^6.4", + "symfony/yaml": "^5.4 || ^6.4", "webmozart/assert": "^1.0", "webmozart/path-util": "^2.3" }, - "suggest": { - "daverandom/libdns": "^2.0" - }, "require-dev": { - "phpspec/prophecy": "^1.9", - "symfony/finder": "^5.0|^6.0", - "symfony/phpunit-bridge": "^5.0|^6.0", - "symfony/var-dumper": "^5.0|^6.0" + "symfony/finder": "^5.4 || ^6.4", + "symfony/phpunit-bridge": "^5.4 || ^6.4", + "symfony/property-access": "^5.4 || ^6.4", + "symfony/var-dumper": "^5.4 || ^6.4" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e94cde70..46e21548 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,7 @@ + diff --git a/src/Cli/Serializer/PemNormalizer.php b/src/Cli/Serializer/PemNormalizer.php index 8053fbb1..2a59ac7e 100644 --- a/src/Cli/Serializer/PemNormalizer.php +++ b/src/Cli/Serializer/PemNormalizer.php @@ -52,4 +52,12 @@ public function supportsDenormalization($data, $type, string $format = null) { return \is_string($data); } + + public function getSupportedTypes(?string $format): array + { + return [ + Certificate::class => true, + Key::class => true, + ]; + } } diff --git a/tests/Cli/Action/InstallAwsElbActionTest.php b/tests/Cli/Action/InstallAwsElbActionTest.php index c507d9b1..2e551f9d 100644 --- a/tests/Cli/Action/InstallAwsElbActionTest.php +++ b/tests/Cli/Action/InstallAwsElbActionTest.php @@ -24,9 +24,12 @@ use Aws\Iam\IamClient; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; class InstallAwsElbActionTest extends TestCase { + use ProphecyTrait; + public function testHandle() { $domain = 'foo.bar'; diff --git a/tests/Cli/Action/InstallAwsElbv2ActionTest.php b/tests/Cli/Action/InstallAwsElbv2ActionTest.php index 1a4d6928..38fa7eb9 100644 --- a/tests/Cli/Action/InstallAwsElbv2ActionTest.php +++ b/tests/Cli/Action/InstallAwsElbv2ActionTest.php @@ -24,9 +24,12 @@ use Aws\Iam\IamClient; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; class InstallAwsElbv2ActionTest extends TestCase { + use ProphecyTrait; + public function testHandle() { $domain = 'foo.bar'; diff --git a/tests/Cli/Repository/RepositoryTest.php b/tests/Cli/Repository/RepositoryTest.php index 4a1d87a6..8fc69de8 100644 --- a/tests/Cli/Repository/RepositoryTest.php +++ b/tests/Cli/Repository/RepositoryTest.php @@ -25,6 +25,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; class RepositoryTest extends TestCase @@ -47,7 +48,7 @@ class RepositoryTest extends TestCase public function setUp(): void { $this->serializer = new Serializer( - [new PemNormalizer(), new GetSetMethodNormalizer()], + [new PemNormalizer(), new ObjectNormalizer()], [new PemEncoder(), new JsonEncoder()] ); diff --git a/tests/Core/Challenge/ChainValidatorTest.php b/tests/Core/Challenge/ChainValidatorTest.php index 900aaaf6..f78e6650 100644 --- a/tests/Core/Challenge/ChainValidatorTest.php +++ b/tests/Core/Challenge/ChainValidatorTest.php @@ -16,9 +16,12 @@ use AcmePhp\Core\Challenge\ValidatorInterface; use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class ChainValidatorTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $mockValidator1 = $this->prophesize(ValidatorInterface::class); diff --git a/tests/Core/Challenge/Dns/DnsDataExtractorTest.php b/tests/Core/Challenge/Dns/DnsDataExtractorTest.php index 9d232fe5..2ed8ab13 100644 --- a/tests/Core/Challenge/Dns/DnsDataExtractorTest.php +++ b/tests/Core/Challenge/Dns/DnsDataExtractorTest.php @@ -15,9 +15,12 @@ use AcmePhp\Core\Http\Base64SafeEncoder; use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class DnsDataExtractorTest extends TestCase { + use ProphecyTrait; + public function testGetRecordName() { $domain = 'foo.com'; diff --git a/tests/Core/Challenge/Dns/DnsValidatorTest.php b/tests/Core/Challenge/Dns/DnsValidatorTest.php index 9b964111..5102380b 100644 --- a/tests/Core/Challenge/Dns/DnsValidatorTest.php +++ b/tests/Core/Challenge/Dns/DnsValidatorTest.php @@ -17,9 +17,12 @@ use AcmePhp\Core\Challenge\SolverInterface; use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class DnsValidatorTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/Dns/GandiSolverTest.php b/tests/Core/Challenge/Dns/GandiSolverTest.php index 19915113..0ed9adc6 100644 --- a/tests/Core/Challenge/Dns/GandiSolverTest.php +++ b/tests/Core/Challenge/Dns/GandiSolverTest.php @@ -16,9 +16,12 @@ use AcmePhp\Core\Protocol\AuthorizationChallenge; use GuzzleHttp\ClientInterface; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class GandiSolverTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/Dns/Route53SolverTest.php b/tests/Core/Challenge/Dns/Route53SolverTest.php index bd9581af..cdbaca5c 100644 --- a/tests/Core/Challenge/Dns/Route53SolverTest.php +++ b/tests/Core/Challenge/Dns/Route53SolverTest.php @@ -17,9 +17,12 @@ use Aws\Route53\Route53Client; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; class Route53SolverTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/Dns/SimpleDnsSolverTest.php b/tests/Core/Challenge/Dns/SimpleDnsSolverTest.php index 7ef38e5d..09be9d71 100644 --- a/tests/Core/Challenge/Dns/SimpleDnsSolverTest.php +++ b/tests/Core/Challenge/Dns/SimpleDnsSolverTest.php @@ -16,10 +16,13 @@ use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Output\OutputInterface; class SimpleDnsSolverTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/Http/FilesystemSolverTest.php b/tests/Core/Challenge/Http/FilesystemSolverTest.php index 3a66986a..75e8e4d1 100644 --- a/tests/Core/Challenge/Http/FilesystemSolverTest.php +++ b/tests/Core/Challenge/Http/FilesystemSolverTest.php @@ -18,10 +18,13 @@ use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Container\ContainerInterface; class FilesystemSolverTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/Http/HttpDataExtractorTest.php b/tests/Core/Challenge/Http/HttpDataExtractorTest.php index f8a4b75e..5b5a8a3c 100644 --- a/tests/Core/Challenge/Http/HttpDataExtractorTest.php +++ b/tests/Core/Challenge/Http/HttpDataExtractorTest.php @@ -14,9 +14,12 @@ use AcmePhp\Core\Challenge\Http\HttpDataExtractor; use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class HttpDataExtractorTest extends TestCase { + use ProphecyTrait; + public function testGetCheckUrl() { $domain = 'foo.com'; diff --git a/tests/Core/Challenge/Http/HttpValidatorTest.php b/tests/Core/Challenge/Http/HttpValidatorTest.php index 116fbe45..1dd1c7e0 100644 --- a/tests/Core/Challenge/Http/HttpValidatorTest.php +++ b/tests/Core/Challenge/Http/HttpValidatorTest.php @@ -18,12 +18,15 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; class HttpValidatorTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/Http/SimpleHttpSolverTest.php b/tests/Core/Challenge/Http/SimpleHttpSolverTest.php index 3c6df104..7b4feb6f 100644 --- a/tests/Core/Challenge/Http/SimpleHttpSolverTest.php +++ b/tests/Core/Challenge/Http/SimpleHttpSolverTest.php @@ -16,10 +16,13 @@ use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Output\OutputInterface; class SimpleHttpSolverTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $typeDns = 'dns-01'; diff --git a/tests/Core/Challenge/WaitingValidatorTest.php b/tests/Core/Challenge/WaitingValidatorTest.php index db230f03..c16ea383 100644 --- a/tests/Core/Challenge/WaitingValidatorTest.php +++ b/tests/Core/Challenge/WaitingValidatorTest.php @@ -16,10 +16,13 @@ use AcmePhp\Core\Challenge\WaitingValidator; use AcmePhp\Core\Protocol\AuthorizationChallenge; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bridge\PhpUnit\ClockMock; class WaitingValidatorTest extends TestCase { + use ProphecyTrait; + public function setUp(): void { parent::setUp(); From c791c3ca80c7fb59ed01c795b0617ee4fd774332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 14:45:06 +0200 Subject: [PATCH 26/77] Update PHP-CS-Fixer to 3.62.0 and run it --- .github/workflows/test-build.yaml | 2 +- src/Cli/Action/AbstractAwsAction.php | 5 +- src/Cli/Action/BuildNginxProxyAction.php | 3 - src/Cli/Action/FilesystemAction.php | 5 +- src/Cli/Action/InstallAliyunCdnAction.php | 3 - src/Cli/Action/InstallAliyunWafAction.php | 3 - src/Cli/Action/InstallCPanelAction.php | 34 ++++++----- src/Cli/Action/PushRancherAction.php | 3 - src/Cli/Application.php | 9 --- src/Cli/Command/AbstractCommand.php | 30 ---------- .../Helper/DistinguishedNameHelper.php | 3 - src/Cli/Command/RevokeCommand.php | 6 -- src/Cli/Command/RunCommand.php | 6 -- src/Cli/Command/SelfUpdateCommand.php | 3 - src/Cli/Command/StatusCommand.php | 6 -- src/Cli/Configuration/DomainConfiguration.php | 3 - src/Cli/Exception/AcmeCliActionException.php | 2 +- src/Cli/Exception/AcmeCliException.php | 2 +- src/Cli/Exception/CommandFlowException.php | 2 +- src/Cli/Monolog/ConsoleFormatter.php | 6 -- src/Cli/Monolog/ConsoleHandler.php | 14 +---- src/Cli/Repository/Repository.php | 60 ------------------- src/Cli/Serializer/PemEncoder.php | 12 ---- src/Cli/Serializer/PemNormalizer.php | 20 ++----- src/Core/AcmeClient.php | 37 ++---------- src/Core/AcmeClientInterface.php | 28 ++++----- src/Core/Challenge/ChainValidator.php | 6 -- src/Core/Challenge/Dns/DnsDataExtractor.php | 2 +- src/Core/Challenge/Dns/DnsValidator.php | 8 +-- src/Core/Challenge/Dns/GandiSolver.php | 17 +----- src/Core/Challenge/Dns/LibDnsResolver.php | 8 +-- src/Core/Challenge/Dns/Route53Solver.php | 19 +----- src/Core/Challenge/Dns/SimpleDnsSolver.php | 15 +---- src/Core/Challenge/Http/FilesystemSolver.php | 11 +--- src/Core/Challenge/Http/HttpValidator.php | 8 +-- src/Core/Challenge/Http/MockHttpValidator.php | 6 -- .../Challenge/Http/MockServerHttpSolver.php | 9 --- src/Core/Challenge/Http/SimpleHttpSolver.php | 11 +--- src/Core/Challenge/WaitingValidator.php | 6 -- .../Exception/AcmeCoreClientException.php | 2 +- .../Exception/AcmeCoreServerException.php | 2 +- .../Exception/AcmeDnsResolutionException.php | 2 +- .../Protocol/ChallengeFailedException.php | 2 +- .../ChallengeNotSupportedException.php | 2 +- .../Protocol/ChallengeTimedOutException.php | 2 +- .../Server/BadCsrServerException.php | 2 +- .../Server/BadNonceServerException.php | 2 +- .../Exception/Server/CaaServerException.php | 2 +- .../Server/ConnectionServerException.php | 2 +- .../Exception/Server/DnsServerException.php | 2 +- .../IncorrectResponseServerException.php | 2 +- .../Server/InternalServerException.php | 2 +- .../Server/InvalidContactServerException.php | 2 +- .../Server/InvalidEmailServerException.php | 2 +- .../Server/MalformedServerException.php | 2 +- .../Server/OrderNotReadyServerException.php | 2 +- .../Server/RateLimitedServerException.php | 2 +- .../RejectedIdentifierServerException.php | 2 +- .../Exception/Server/TlsServerException.php | 2 +- .../Server/UnauthorizedServerException.php | 2 +- .../Server/UnknownHostServerException.php | 2 +- .../UnsupportedContactServerException.php | 2 +- .../UnsupportedIdentifierServerException.php | 2 +- .../UserActionRequiredServerException.php | 2 +- .../Adapter/FlysystemFtpFactory.php | 3 - .../Adapter/FlysystemLocalFactory.php | 3 - .../Adapter/FlysystemSftpFactory.php | 3 - src/Core/Http/SecureHttpClient.php | 12 ++-- src/Core/Http/ServerErrorHandler.php | 4 +- src/Core/Protocol/CertificateOrder.php | 2 +- src/Core/Util/JsonDecoder.php | 2 - src/Ssl/Certificate.php | 2 +- src/Ssl/DistinguishedName.php | 12 ++-- src/Ssl/Generator/KeyPairGenerator.php | 4 +- src/Ssl/ParsedCertificate.php | 14 ++--- src/Ssl/PrivateKey.php | 3 - src/Ssl/PublicKey.php | 3 - tests/Cli/Repository/RepositoryTest.php | 1 - tests/Ssl/CertificateTest.php | 2 +- 79 files changed, 110 insertions(+), 443 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 9adfb417..38b8644b 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@master - name: Install php-cs-fixer - run: wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.4.0/php-cs-fixer.phar -q + run: wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.62.0/php-cs-fixer.phar -q - name: Check coding style run: php php-cs-fixer.phar fix --dry-run --diff diff --git a/src/Cli/Action/AbstractAwsAction.php b/src/Cli/Action/AbstractAwsAction.php index baea6df9..24d2ddcc 100644 --- a/src/Cli/Action/AbstractAwsAction.php +++ b/src/Cli/Action/AbstractAwsAction.php @@ -32,9 +32,6 @@ public function __construct(ClientFactory $clientFactory) $this->clientFactory = $clientFactory; } - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $this->assertConfiguration($config, ['loadbalancer', 'region']); @@ -87,7 +84,7 @@ private function cleanupOldCertificates($region, $certificatePrefix, $certificat ) { try { $this->retryCall( - // Try several time to delete certificate given AWS takes time to uninstall previous one + // Try several time to delete certificate given AWS takes time to uninstall previous one function () use ($iamClient, $certificate) { $iamClient->deleteServerCertificate( ['ServerCertificateName' => $certificate['ServerCertificateName']] diff --git a/src/Cli/Action/BuildNginxProxyAction.php b/src/Cli/Action/BuildNginxProxyAction.php index dac28a9b..6377f27a 100644 --- a/src/Cli/Action/BuildNginxProxyAction.php +++ b/src/Cli/Action/BuildNginxProxyAction.php @@ -34,9 +34,6 @@ public function __construct(RepositoryInterface $repository) $this->repository = $repository; } - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $domain = $response->getCertificateRequest()->getDistinguishedName()->getCommonName(); diff --git a/src/Cli/Action/FilesystemAction.php b/src/Cli/Action/FilesystemAction.php index cede6e8d..258b7030 100644 --- a/src/Cli/Action/FilesystemAction.php +++ b/src/Cli/Action/FilesystemAction.php @@ -33,15 +33,12 @@ class FilesystemAction extends AbstractAction */ protected $filesystemFactoryLocator; - public function __construct(FlysystemFilesystemInterface $storage, ContainerInterface $locator = null) + public function __construct(FlysystemFilesystemInterface $storage, ?ContainerInterface $locator = null) { $this->storage = $storage; $this->filesystemFactoryLocator = $locator ?: new ServiceLocator([]); } - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $this->assertConfiguration($config, ['adapter']); diff --git a/src/Cli/Action/InstallAliyunCdnAction.php b/src/Cli/Action/InstallAliyunCdnAction.php index a30018e8..dcdea45d 100644 --- a/src/Cli/Action/InstallAliyunCdnAction.php +++ b/src/Cli/Action/InstallAliyunCdnAction.php @@ -22,9 +22,6 @@ */ class InstallAliyunCdnAction extends AbstractAction { - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $issuerChain = []; diff --git a/src/Cli/Action/InstallAliyunWafAction.php b/src/Cli/Action/InstallAliyunWafAction.php index 86bcb01e..8ccff2ec 100644 --- a/src/Cli/Action/InstallAliyunWafAction.php +++ b/src/Cli/Action/InstallAliyunWafAction.php @@ -22,9 +22,6 @@ */ class InstallAliyunWafAction extends AbstractAction { - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $issuerChain = []; diff --git a/src/Cli/Action/InstallCPanelAction.php b/src/Cli/Action/InstallCPanelAction.php index 6efbdc95..cb7fef8d 100644 --- a/src/Cli/Action/InstallCPanelAction.php +++ b/src/Cli/Action/InstallCPanelAction.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace AcmePhp\Cli\Action; use AcmePhp\Ssl\Certificate; @@ -18,9 +27,6 @@ public function __construct(Client $httpClient) $this->httpClient = $httpClient; } - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $this->assertConfiguration($config, ['host', 'username', 'token']); @@ -44,15 +50,15 @@ public function handle(array $config, CertificateResponse $response) private function installCertificate($config, $domain, $crt, $caBundle, $key) { - $this->httpClient->request('POST', $config['host'] . 'json-api/cpanel?' . - 'cpanel_jsonapi_apiversion=2&' . - 'cpanel_jsonapi_module=SSL&' . - 'cpanel_jsonapi_func=installssl&' . - 'domain=' . $domain . '&' . - 'crt=' . urlencode($crt) . '&' . - 'key=' . urlencode($key) . '&' . - 'cabundle=' . urlencode($caBundle), - ['headers' => ['Authorization' => 'cpanel ' . $config['username'] . ':' . $config['token']], - ]); + $this->httpClient->request('POST', $config['host'].'json-api/cpanel?'. + 'cpanel_jsonapi_apiversion=2&'. + 'cpanel_jsonapi_module=SSL&'. + 'cpanel_jsonapi_func=installssl&'. + 'domain='.$domain.'&'. + 'crt='.urlencode($crt).'&'. + 'key='.urlencode($key).'&'. + 'cabundle='.urlencode($caBundle), + ['headers' => ['Authorization' => 'cpanel '.$config['username'].':'.$config['token']], + ]); } -} \ No newline at end of file +} diff --git a/src/Cli/Action/PushRancherAction.php b/src/Cli/Action/PushRancherAction.php index c1785a42..015804ea 100644 --- a/src/Cli/Action/PushRancherAction.php +++ b/src/Cli/Action/PushRancherAction.php @@ -35,9 +35,6 @@ public function __construct(Client $httpClient) $this->httpClient = $httpClient; } - /** - * {@inheritdoc} - */ public function handle(array $config, CertificateResponse $response) { $payload = $this->createRancherPayloadFromResponse($response); diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 19bb14db..ae5a98cb 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -31,17 +31,11 @@ class Application extends BaseApplication 'localhost' => 'https://localhost:14000/dir', ]; - /** - * {@inheritdoc} - */ public function __construct() { parent::__construct('Acme PHP - Let\'s Encrypt/ZeroSSL client', '2.0.0'); } - /** - * {@inheritdoc} - */ protected function getDefaultCommands(): array { return array_merge(parent::getDefaultCommands(), [ @@ -52,9 +46,6 @@ protected function getDefaultCommands(): array ]); } - /** - * {@inheritdoc} - */ protected function getDefaultHelperSet(): HelperSet { $set = parent::getDefaultHelperSet(); diff --git a/src/Cli/Command/AbstractCommand.php b/src/Cli/Command/AbstractCommand.php index 35162886..408bd164 100644 --- a/src/Cli/Command/AbstractCommand.php +++ b/src/Cli/Command/AbstractCommand.php @@ -47,9 +47,6 @@ abstract class AbstractCommand extends Command implements LoggerInterface */ private $container; - /** - * {@inheritdoc} - */ protected function initialize(InputInterface $input, OutputInterface $output) { $this->input = $input; @@ -134,73 +131,46 @@ private function initializeContainer() $this->container->set('output', $this->output); } - /** - * {@inheritdoc} - */ public function emergency($message, array $context = []) { return $this->getCliLogger()->emergency($message, $context); } - /** - * {@inheritdoc} - */ public function alert($message, array $context = []) { return $this->getCliLogger()->alert($message, $context); } - /** - * {@inheritdoc} - */ public function critical($message, array $context = []) { return $this->getCliLogger()->critical($message, $context); } - /** - * {@inheritdoc} - */ public function error($message, array $context = []) { return $this->getCliLogger()->error($message, $context); } - /** - * {@inheritdoc} - */ public function warning($message, array $context = []) { return $this->getCliLogger()->warning($message, $context); } - /** - * {@inheritdoc} - */ public function notice($message, array $context = []) { return $this->getCliLogger()->notice($message, $context); } - /** - * {@inheritdoc} - */ public function info($message, array $context = []) { return $this->getCliLogger()->info($message, $context); } - /** - * {@inheritdoc} - */ public function debug($message, array $context = []) { return $this->getCliLogger()->debug($message, $context); } - /** - * {@inheritdoc} - */ public function log($level, $message, array $context = []) { return $this->getCliLogger()->log($level, $message, $context); diff --git a/src/Cli/Command/Helper/DistinguishedNameHelper.php b/src/Cli/Command/Helper/DistinguishedNameHelper.php index cb34c4bf..5b0452b7 100644 --- a/src/Cli/Command/Helper/DistinguishedNameHelper.php +++ b/src/Cli/Command/Helper/DistinguishedNameHelper.php @@ -23,9 +23,6 @@ */ class DistinguishedNameHelper extends Helper { - /** - * {@inheritdoc} - */ public function getName() { return 'distinguished_name'; diff --git a/src/Cli/Command/RevokeCommand.php b/src/Cli/Command/RevokeCommand.php index 29f85def..18e4e227 100644 --- a/src/Cli/Command/RevokeCommand.php +++ b/src/Cli/Command/RevokeCommand.php @@ -21,9 +21,6 @@ class RevokeCommand extends AbstractCommand { - /** - * {@inheritdoc} - */ protected function configure() { $reasons = implode(PHP_EOL, RevocationReason::getFormattedReasons()); @@ -44,9 +41,6 @@ protected function configure() ->setHelp('The %command.name% command revoke a previously obtained certificate for a given domain'); } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output) { if (!isset(Application::PROVIDERS[$this->input->getOption('provider')])) { diff --git a/src/Cli/Command/RunCommand.php b/src/Cli/Command/RunCommand.php index 1a70880c..cca39a3c 100644 --- a/src/Cli/Command/RunCommand.php +++ b/src/Cli/Command/RunCommand.php @@ -50,9 +50,6 @@ class RunCommand extends AbstractCommand private $config; - /** - * {@inheritdoc} - */ protected function configure() { $this->setName('run') @@ -72,9 +69,6 @@ protected function configure() ->setHelp('The %command.name% challenge the domains, request the certificates and install them following a given configuration.'); } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output) { $this->config = $this->getConfig(Path::makeAbsolute($input->getArgument('config'), getcwd())); diff --git a/src/Cli/Command/SelfUpdateCommand.php b/src/Cli/Command/SelfUpdateCommand.php index b2f03b33..8e6024d9 100644 --- a/src/Cli/Command/SelfUpdateCommand.php +++ b/src/Cli/Command/SelfUpdateCommand.php @@ -87,9 +87,6 @@ protected function configure() ); } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; diff --git a/src/Cli/Command/StatusCommand.php b/src/Cli/Command/StatusCommand.php index 524b9b56..a54997b3 100644 --- a/src/Cli/Command/StatusCommand.php +++ b/src/Cli/Command/StatusCommand.php @@ -23,9 +23,6 @@ */ class StatusCommand extends AbstractCommand { - /** - * {@inheritdoc} - */ protected function configure() { $this->setName('status') @@ -38,9 +35,6 @@ protected function configure() ); } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output) { $repository = $this->getRepository(); diff --git a/src/Cli/Configuration/DomainConfiguration.php b/src/Cli/Configuration/DomainConfiguration.php index 99040495..251bde9f 100644 --- a/src/Cli/Configuration/DomainConfiguration.php +++ b/src/Cli/Configuration/DomainConfiguration.php @@ -20,9 +20,6 @@ */ class DomainConfiguration implements ConfigurationInterface { - /** - * {@inheritdoc} - */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('acmephp'); diff --git a/src/Cli/Exception/AcmeCliActionException.php b/src/Cli/Exception/AcmeCliActionException.php index fa785b61..2275e275 100644 --- a/src/Cli/Exception/AcmeCliActionException.php +++ b/src/Cli/Exception/AcmeCliActionException.php @@ -16,7 +16,7 @@ */ class AcmeCliActionException extends AcmeCliException { - public function __construct(string $actionName, \Exception $previous = null) + public function __construct(string $actionName, ?\Exception $previous = null) { parent::__construct(sprintf('An exception was thrown during action "%s"', $actionName), $previous); } diff --git a/src/Cli/Exception/AcmeCliException.php b/src/Cli/Exception/AcmeCliException.php index b5f4c0c7..321021a9 100644 --- a/src/Cli/Exception/AcmeCliException.php +++ b/src/Cli/Exception/AcmeCliException.php @@ -16,7 +16,7 @@ */ class AcmeCliException extends \RuntimeException { - public function __construct($message, \Exception $previous = null) + public function __construct($message, ?\Exception $previous = null) { parent::__construct($message, 0, $previous); } diff --git a/src/Cli/Exception/CommandFlowException.php b/src/Cli/Exception/CommandFlowException.php index fcaafe96..387577e8 100644 --- a/src/Cli/Exception/CommandFlowException.php +++ b/src/Cli/Exception/CommandFlowException.php @@ -25,7 +25,7 @@ class CommandFlowException extends AcmeCliException * @param string $command Name of the command to run in order to fix the flow * @param array $arguments Optional list of missing arguments */ - public function __construct(string $missing, string $command, array $arguments = [], \Exception $previous = null) + public function __construct(string $missing, string $command, array $arguments = [], ?\Exception $previous = null) { $this->missing = $missing; $this->command = $command; diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index e9ad5281..36346f2f 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -27,17 +27,11 @@ class ConsoleFormatter extends LineFormatter { public const SIMPLE_FORMAT = "%start_tag%%message% %context% %extra%%end_tag%\n"; - /** - * {@inheritdoc} - */ public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false, $ignoreEmptyContextAndExtra = true) { parent::__construct($format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra); } - /** - * {@inheritdoc} - */ public function format(array $record): string { if ($record['level'] >= Logger::ERROR) { diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index 45cc8bde..f509b638 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -52,7 +52,7 @@ class ConsoleHandler extends AbstractProcessingHandler * @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging * level (leave empty to use the default mapping) */ - public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = []) + public function __construct(?OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = []) { parent::__construct(Logger::DEBUG, $bubble); @@ -63,17 +63,11 @@ public function __construct(OutputInterface $output = null, bool $bubble = true, } } - /** - * {@inheritdoc} - */ public function isHandling(array $record): bool { return $this->updateLevel() && parent::isHandling($record); } - /** - * {@inheritdoc} - */ public function handle(array $record): bool { // we have to update the logging level each time because the verbosity of the @@ -101,17 +95,11 @@ public function close(): void parent::close(); } - /** - * {@inheritdoc} - */ protected function write(array $record): void { $this->output->write((string) $record['formatted']); } - /** - * {@inheritdoc} - */ protected function getDefaultFormatter(): FormatterInterface { $formatter = new ConsoleFormatter(); diff --git a/src/Cli/Repository/Repository.php b/src/Cli/Repository/Repository.php index 0b475b16..fd80e8d2 100644 --- a/src/Cli/Repository/Repository.php +++ b/src/Cli/Repository/Repository.php @@ -60,9 +60,6 @@ public function __construct(SerializerInterface $serializer, FilesystemInterface $this->storage = $storage; } - /** - * {@inheritdoc} - */ public function storeCertificateResponse(CertificateResponse $certificateResponse) { $distinguishedName = $certificateResponse->getCertificateRequest()->getDistinguishedName(); @@ -73,9 +70,6 @@ public function storeCertificateResponse(CertificateResponse $certificateRespons $this->storeDomainCertificate($domain, $certificateResponse->getCertificate()); } - /** - * {@inheritdoc} - */ public function storeAccountKeyPair(KeyPair $keyPair) { try { @@ -93,17 +87,11 @@ public function storeAccountKeyPair(KeyPair $keyPair) } } - /** - * {@inheritdoc} - */ public function hasAccountKeyPair(): bool { return $this->storage->has(self::PATH_ACCOUNT_KEY_PRIVATE); } - /** - * {@inheritdoc} - */ public function loadAccountKeyPair(): KeyPair { try { @@ -119,9 +107,6 @@ public function loadAccountKeyPair(): KeyPair } } - /** - * {@inheritdoc} - */ public function storeDomainKeyPair(string $domain, KeyPair $keyPair) { try { @@ -139,17 +124,11 @@ public function storeDomainKeyPair(string $domain, KeyPair $keyPair) } } - /** - * {@inheritdoc} - */ public function hasDomainKeyPair(string $domain): bool { return $this->storage->has($this->getPathForDomain(self::PATH_DOMAIN_KEY_PRIVATE, $domain)); } - /** - * {@inheritdoc} - */ public function loadDomainKeyPair(string $domain): KeyPair { try { @@ -165,9 +144,6 @@ public function loadDomainKeyPair(string $domain): KeyPair } } - /** - * {@inheritdoc} - */ public function storeDomainAuthorizationChallenge(string $domain, AuthorizationChallenge $authorizationChallenge) { try { @@ -180,17 +156,11 @@ public function storeDomainAuthorizationChallenge(string $domain, AuthorizationC } } - /** - * {@inheritdoc} - */ public function hasDomainAuthorizationChallenge(string $domain): bool { return $this->storage->has($this->getPathForDomain(self::PATH_CACHE_AUTHORIZATION_CHALLENGE, $domain)); } - /** - * {@inheritdoc} - */ public function loadDomainAuthorizationChallenge(string $domain): AuthorizationChallenge { try { @@ -202,9 +172,6 @@ public function loadDomainAuthorizationChallenge(string $domain): AuthorizationC } } - /** - * {@inheritdoc} - */ public function storeDomainDistinguishedName(string $domain, DistinguishedName $distinguishedName) { try { @@ -217,17 +184,11 @@ public function storeDomainDistinguishedName(string $domain, DistinguishedName $ } } - /** - * {@inheritdoc} - */ public function hasDomainDistinguishedName(string $domain): bool { return $this->storage->has($this->getPathForDomain(self::PATH_CACHE_DISTINGUISHED_NAME, $domain)); } - /** - * {@inheritdoc} - */ public function loadDomainDistinguishedName(string $domain): DistinguishedName { try { @@ -239,9 +200,6 @@ public function loadDomainDistinguishedName(string $domain): DistinguishedName } } - /** - * {@inheritdoc} - */ public function storeDomainCertificate(string $domain, Certificate $certificate) { // Simple certificate @@ -272,17 +230,11 @@ public function storeDomainCertificate(string $domain, Certificate $certificate) $this->save($this->getPathForDomain(self::PATH_DOMAIN_CERT_COMBINED, $domain), $combinedPem); } - /** - * {@inheritdoc} - */ public function hasDomainCertificate(string $domain): bool { return $this->storage->has($this->getPathForDomain(self::PATH_DOMAIN_CERT_FULLCHAIN, $domain)); } - /** - * {@inheritdoc} - */ public function loadDomainCertificate(string $domain): Certificate { try { @@ -309,9 +261,6 @@ public function loadDomainCertificate(string $domain): Certificate return $certificate; } - /** - * {@inheritdoc} - */ public function storeCertificateOrder(array $domains, CertificateOrder $order) { try { @@ -324,17 +273,11 @@ public function storeCertificateOrder(array $domains, CertificateOrder $order) } } - /** - * {@inheritdoc} - */ public function hasCertificateOrder(array $domains): bool { return $this->storage->has($this->getPathForDomainList(self::PATH_CACHE_CERTIFICATE_ORDER, $domains)); } - /** - * {@inheritdoc} - */ public function loadCertificateOrder(array $domains): CertificateOrder { try { @@ -346,9 +289,6 @@ public function loadCertificateOrder(array $domains): CertificateOrder } } - /** - * {@inheritdoc} - */ public function save(string $path, string $content, string $visibility = self::VISIBILITY_PRIVATE) { if (!$this->storage->has($path)) { diff --git a/src/Cli/Serializer/PemEncoder.php b/src/Cli/Serializer/PemEncoder.php index d9f15c35..e1f0a459 100644 --- a/src/Cli/Serializer/PemEncoder.php +++ b/src/Cli/Serializer/PemEncoder.php @@ -21,33 +21,21 @@ class PemEncoder implements EncoderInterface, DecoderInterface { public const FORMAT = 'pem'; - /** - * {@inheritdoc} - */ public function encode($data, $format, array $context = []): string { return trim($data)."\n"; } - /** - * {@inheritdoc} - */ public function decode($data, $format, array $context = []) { return trim($data)."\n"; } - /** - * {@inheritdoc} - */ public function supportsEncoding($format): bool { return self::FORMAT === $format; } - /** - * {@inheritdoc} - */ public function supportsDecoding($format) { return self::FORMAT === $format; diff --git a/src/Cli/Serializer/PemNormalizer.php b/src/Cli/Serializer/PemNormalizer.php index 2a59ac7e..0b9f8f57 100644 --- a/src/Cli/Serializer/PemNormalizer.php +++ b/src/Cli/Serializer/PemNormalizer.php @@ -21,34 +21,22 @@ */ class PemNormalizer implements NormalizerInterface, DenormalizerInterface { - /** - * {@inheritdoc} - */ - public function normalize($object, string $format = null, array $context = []) + public function normalize($object, ?string $format = null, array $context = []) { return $object->getPEM(); } - /** - * {@inheritdoc} - */ - public function denormalize($data, $class, string $format = null, array $context = []) + public function denormalize($data, $class, ?string $format = null, array $context = []) { return new $class($data); } - /** - * {@inheritdoc} - */ - public function supportsNormalization($data, string $format = null) + public function supportsNormalization($data, ?string $format = null) { return \is_object($data) && ($data instanceof Certificate || $data instanceof Key); } - /** - * {@inheritdoc} - */ - public function supportsDenormalization($data, $type, string $format = null) + public function supportsDenormalization($data, $type, ?string $format = null) { return \is_string($data); } diff --git a/src/Core/AcmeClient.php b/src/Core/AcmeClient.php index cae90bc6..50ab20ac 100644 --- a/src/Core/AcmeClient.php +++ b/src/Core/AcmeClient.php @@ -68,17 +68,14 @@ class AcmeClient implements AcmeClientInterface */ private $account; - public function __construct(SecureHttpClient $httpClient, string $directoryUrl, CertificateRequestSigner $csrSigner = null) + public function __construct(SecureHttpClient $httpClient, string $directoryUrl, ?CertificateRequestSigner $csrSigner = null) { $this->uninitializedHttpClient = $httpClient; $this->directoryUrl = $directoryUrl; $this->csrSigner = $csrSigner ?: new CertificateRequestSigner(); } - /** - * {@inheritdoc} - */ - public function registerAccount(string $email = null, ExternalAccount $externalAccount = null): array + public function registerAccount(?string $email = null, ?ExternalAccount $externalAccount = null): array { $client = $this->getHttpClient(); @@ -104,9 +101,6 @@ public function registerAccount(string $email = null, ExternalAccount $externalA return $client->request('POST', $account, $client->signKidPayload($account, $account, null)); } - /** - * {@inheritdoc} - */ public function requestOrder(array $domains): CertificateOrder { Assert::allStringNotEmpty($domains, 'requestOrder::$domains expected a list of strings. Got: %s'); @@ -143,9 +137,6 @@ static function ($domain) { return new CertificateOrder($authorizationsChallenges, $orderEndpoint, $response['status']); } - /** - * {@inheritdoc} - */ public function reloadOrder(CertificateOrder $order): CertificateOrder { $client = $this->getHttpClient(); @@ -168,9 +159,6 @@ public function reloadOrder(CertificateOrder $order): CertificateOrder return new CertificateOrder($authorizationsChallenges, $orderEndpoint, $response['status']); } - /** - * {@inheritdoc} - */ public function finalizeOrder(CertificateOrder $order, CertificateRequest $csr, int $timeout = 180, bool $returnAlternateCertificateIfAvailable = false): CertificateResponse { $endTime = time() + $timeout; @@ -216,9 +204,6 @@ public function finalizeOrder(CertificateOrder $order, CertificateRequest $csr, return $this->createCertificateResponse($csr, Utils::copyToString($response->getBody())); } - /** - * {@inheritdoc} - */ public function requestAuthorization(string $domain): array { $order = $this->requestOrder([$domain]); @@ -230,9 +215,6 @@ public function requestAuthorization(string $domain): array } } - /** - * {@inheritdoc} - */ public function reloadAuthorization(AuthorizationChallenge $challenge): AuthorizationChallenge { $client = $this->getHttpClient(); @@ -242,9 +224,6 @@ public function reloadAuthorization(AuthorizationChallenge $challenge): Authoriz return $this->createAuthorizationChallenge($challenge->getDomain(), $response); } - /** - * {@inheritdoc} - */ public function challengeAuthorization(AuthorizationChallenge $challenge, int $timeout = 180): array { $endTime = time() + $timeout; @@ -271,9 +250,6 @@ public function challengeAuthorization(AuthorizationChallenge $challenge, int $t return $response; } - /** - * {@inheritdoc} - */ public function requestCertificate(string $domain, CertificateRequest $csr, int $timeout = 180, bool $returnAlternateCertificateIfAvailable = false): CertificateResponse { $order = $this->requestOrder(array_unique(array_merge([$domain], $csr->getDistinguishedName()->getSubjectAlternativeNames()))); @@ -281,10 +257,7 @@ public function requestCertificate(string $domain, CertificateRequest $csr, int return $this->finalizeOrder($order, $csr, $timeout, $returnAlternateCertificateIfAvailable); } - /** - * {@inheritdoc} - */ - public function revokeCertificate(Certificate $certificate, RevocationReason $revocationReason = null) + public function revokeCertificate(Certificate $certificate, ?RevocationReason $revocationReason = null) { if (!$endpoint = $this->getResourceUrl(ResourcesDirectory::REVOKE_CERT)) { throw new CertificateRevocationException('This ACME server does not support certificate revocation.'); @@ -332,10 +305,10 @@ public function getResourceUrl(string $resource): string /** * Request a resource (URL is found using ACME server directory). * + * @return array|string + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * @throws AcmeCoreClientException when an error occured during response parsing - * - * @return array|string */ protected function requestResource(string $method, string $resource, array $payload, bool $returnJson = true) { diff --git a/src/Core/AcmeClientInterface.php b/src/Core/AcmeClientInterface.php index e035bbd7..3ac4440d 100644 --- a/src/Core/AcmeClientInterface.php +++ b/src/Core/AcmeClientInterface.php @@ -40,13 +40,13 @@ interface AcmeClientInterface * @param string|null $email an optionnal e-mail to associate with the account * @param ExternalAccount|null $externalAccount an optionnal External Account to use for External Account Binding * + * @return array the Certificate Authority response decoded from JSON into an array + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * (the exception will be more specific if detail is provided) * @throws AcmeCoreClientException when an error occured during response parsing - * - * @return array the Certificate Authority response decoded from JSON into an array */ - public function registerAccount(string $email = null, ExternalAccount $externalAccount = null): array; + public function registerAccount(?string $email = null, ?ExternalAccount $externalAccount = null): array; /** * Request authorization challenge data for a list of domains. @@ -57,12 +57,12 @@ public function registerAccount(string $email = null, ExternalAccount $externalA * * @param string[] $domains the domains to challenge * + * @return CertificateOrder the Order returned by the Certificate Authority + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * (the exception will be more specific if detail is provided) * @throws AcmeCoreClientException when an error occured during response parsing * @throws ChallengeNotSupportedException when the HTTP challenge is not supported by the server - * - * @return CertificateOrder the Order returned by the Certificate Authority */ public function requestOrder(array $domains): CertificateOrder; @@ -89,13 +89,13 @@ public function reloadOrder(CertificateOrder $order): CertificateOrder; * This is especially useful following * https://letsencrypt.org/2019/04/15/transitioning-to-isrg-root.html. * + * @return CertificateResponse the certificate data to save it somewhere you want + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * (the exception will be more specific if detail is provided) * @throws AcmeCoreClientException when an error occured during response parsing * @throws CertificateRequestFailedException when the certificate request failed * @throws CertificateRequestTimedOutException when the certificate request timed out - * - * @return CertificateResponse the certificate data to save it somewhere you want */ public function finalizeOrder(CertificateOrder $order, CertificateRequest $csr, int $timeout = 180, bool $returnAlternateCertificateIfAvailable = false): CertificateResponse; @@ -108,12 +108,12 @@ public function finalizeOrder(CertificateOrder $order, CertificateRequest $csr, * * @param string $domain the domain to challenge * + * @return AuthorizationChallenge[] the list of challenges data returned by the Certificate Authority + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * (the exception will be more specific if detail is provided) * @throws AcmeCoreClientException when an error occured during response parsing * @throws ChallengeNotSupportedException when the HTTP challenge is not supported by the server - * - * @return AuthorizationChallenge[] the list of challenges data returned by the Certificate Authority */ public function requestAuthorization(string $domain): array; @@ -140,13 +140,13 @@ public function reloadAuthorization(AuthorizationChallenge $challenge): Authoriz * @param AuthorizationChallenge $challenge the challenge data to check * @param int $timeout the timeout period * + * @return array the validate challenge response + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * (the exception will be more specific if detail is provided) * @throws AcmeCoreClientException when an error occured during response parsing * @throws ChallengeTimedOutException when the challenge timed out * @throws ChallengeFailedException when the challenge failed - * - * @return array the validate challenge response */ public function challengeAuthorization(AuthorizationChallenge $challenge, int $timeout = 180): array; @@ -168,13 +168,13 @@ public function challengeAuthorization(AuthorizationChallenge $challenge, int $t * This is especially useful following * https://letsencrypt.org/2019/04/15/transitioning-to-isrg-root.html. * + * @return CertificateResponse the certificate data to save it somewhere you want + * * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code * (the exception will be more specific if detail is provided) * @throws AcmeCoreClientException when an error occured during response parsing * @throws CertificateRequestFailedException when the certificate request failed * @throws CertificateRequestTimedOutException when the certificate request timed out - * - * @return CertificateResponse the certificate data to save it somewhere you want */ public function requestCertificate(string $domain, CertificateRequest $csr, int $timeout = 180, bool $returnAlternateCertificateIfAvailable = false): CertificateResponse; @@ -183,5 +183,5 @@ public function requestCertificate(string $domain, CertificateRequest $csr, int * * @throws CertificateRevocationException */ - public function revokeCertificate(Certificate $certificate, RevocationReason $revocationReason = null); + public function revokeCertificate(Certificate $certificate, ?RevocationReason $revocationReason = null); } diff --git a/src/Core/Challenge/ChainValidator.php b/src/Core/Challenge/ChainValidator.php index 30552372..c9ec5481 100644 --- a/src/Core/Challenge/ChainValidator.php +++ b/src/Core/Challenge/ChainValidator.php @@ -32,9 +32,6 @@ public function __construct(array $validators) $this->validators = $validators; } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { foreach ($this->validators as $validator) { @@ -46,9 +43,6 @@ public function supports(AuthorizationChallenge $authorizationChallenge, SolverI return false; } - /** - * {@inheritdoc} - */ public function isValid(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { foreach ($this->validators as $validator) { diff --git a/src/Core/Challenge/Dns/DnsDataExtractor.php b/src/Core/Challenge/Dns/DnsDataExtractor.php index b64ea733..135b774d 100644 --- a/src/Core/Challenge/Dns/DnsDataExtractor.php +++ b/src/Core/Challenge/Dns/DnsDataExtractor.php @@ -24,7 +24,7 @@ class DnsDataExtractor /** @var Base64SafeEncoder */ private $encoder; - public function __construct(Base64SafeEncoder $encoder = null) + public function __construct(?Base64SafeEncoder $encoder = null) { $this->encoder = $encoder ?: new Base64SafeEncoder(); } diff --git a/src/Core/Challenge/Dns/DnsValidator.php b/src/Core/Challenge/Dns/DnsValidator.php index 998da9d9..bb6d9333 100644 --- a/src/Core/Challenge/Dns/DnsValidator.php +++ b/src/Core/Challenge/Dns/DnsValidator.php @@ -33,7 +33,7 @@ class DnsValidator implements ValidatorInterface */ private $dnsResolver; - public function __construct(DnsDataExtractor $extractor = null, DnsResolverInterface $dnsResolver = null) + public function __construct(?DnsDataExtractor $extractor = null, ?DnsResolverInterface $dnsResolver = null) { $this->extractor = $extractor ?: new DnsDataExtractor(); @@ -43,17 +43,11 @@ public function __construct(DnsDataExtractor $extractor = null, DnsResolverInter } } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { return 'dns-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function isValid(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { $recordName = $this->extractor->getRecordName($authorizationChallenge); diff --git a/src/Core/Challenge/Dns/GandiSolver.php b/src/Core/Challenge/Dns/GandiSolver.php index a4ad28b5..eb52c0a0 100644 --- a/src/Core/Challenge/Dns/GandiSolver.php +++ b/src/Core/Challenge/Dns/GandiSolver.php @@ -49,7 +49,7 @@ class GandiSolver implements MultipleChallengesSolverInterface, ConfigurableServ */ private $apiKey; - public function __construct(DnsDataExtractor $extractor = null, ClientInterface $client = null) + public function __construct(?DnsDataExtractor $extractor = null, ?ClientInterface $client = null) { $this->extractor = $extractor ?: new DnsDataExtractor(); $this->client = $client ?: new Client(); @@ -64,25 +64,16 @@ public function configure(array $config) $this->apiKey = $config['api_key']; } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge): bool { return 'dns-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function solve(AuthorizationChallenge $authorizationChallenge) { return $this->solveAll([$authorizationChallenge]); } - /** - * {@inheritdoc} - */ public function solveAll(array $authorizationChallenges) { Assert::allIsInstanceOf($authorizationChallenges, AuthorizationChallenge::class); @@ -112,17 +103,11 @@ public function solveAll(array $authorizationChallenges) } } - /** - * {@inheritdoc} - */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { return $this->cleanupAll([$authorizationChallenge]); } - /** - * {@inheritdoc} - */ public function cleanupAll(array $authorizationChallenges) { Assert::allIsInstanceOf($authorizationChallenges, AuthorizationChallenge::class); diff --git a/src/Core/Challenge/Dns/LibDnsResolver.php b/src/Core/Challenge/Dns/LibDnsResolver.php index 3030da2e..2fa888b6 100644 --- a/src/Core/Challenge/Dns/LibDnsResolver.php +++ b/src/Core/Challenge/Dns/LibDnsResolver.php @@ -58,10 +58,10 @@ class LibDnsResolver implements DnsResolverInterface private $nameServer; public function __construct( - QuestionFactory $questionFactory = null, - MessageFactory $messageFactory = null, - Encoder $encoder = null, - Decoder $decoder = null, + ?QuestionFactory $questionFactory = null, + ?MessageFactory $messageFactory = null, + ?Encoder $encoder = null, + ?Decoder $decoder = null, $nameServer = '8.8.8.8' ) { $this->questionFactory = $questionFactory ?: new QuestionFactory(); diff --git a/src/Core/Challenge/Dns/Route53Solver.php b/src/Core/Challenge/Dns/Route53Solver.php index 6f28f8b2..53975320 100644 --- a/src/Core/Challenge/Dns/Route53Solver.php +++ b/src/Core/Challenge/Dns/Route53Solver.php @@ -43,32 +43,23 @@ class Route53Solver implements MultipleChallengesSolverInterface */ private $cacheZones; - public function __construct(DnsDataExtractor $extractor = null, Route53Client $client = null) + public function __construct(?DnsDataExtractor $extractor = null, ?Route53Client $client = null) { $this->extractor = $extractor ?: new DnsDataExtractor(); $this->client = $client ?: new Route53Client([]); $this->logger = new NullLogger(); } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge): bool { return 'dns-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function solve(AuthorizationChallenge $authorizationChallenge) { return $this->solveAll([$authorizationChallenge]); } - /** - * {@inheritdoc} - */ public function solveAll(array $authorizationChallenges) { Assert::allIsInstanceOf($authorizationChallenges, AuthorizationChallenge::class); @@ -114,17 +105,11 @@ public function solveAll(array $authorizationChallenges) } } - /** - * {@inheritdoc} - */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { return $this->cleanupAll([$authorizationChallenge]); } - /** - * {@inheritdoc} - */ public function cleanupAll(array $authorizationChallenges) { Assert::allIsInstanceOf($authorizationChallenges, AuthorizationChallenge::class); @@ -198,7 +183,7 @@ function ($recordSet) use ($recordName) { private function getSaveRecordQuery($recordName, array $recordIndex) { - //remove old indexes + // remove old indexes $limitTime = time() - 86400; foreach ($recordIndex as $recordValue => $time) { if ($time < $limitTime) { diff --git a/src/Core/Challenge/Dns/SimpleDnsSolver.php b/src/Core/Challenge/Dns/SimpleDnsSolver.php index 80535f09..f5703acd 100644 --- a/src/Core/Challenge/Dns/SimpleDnsSolver.php +++ b/src/Core/Challenge/Dns/SimpleDnsSolver.php @@ -33,27 +33,17 @@ class SimpleDnsSolver implements SolverInterface */ protected $output; - /** - * @param DnsDataExtractor $extractor - * @param OutputInterface $output - */ - public function __construct(DnsDataExtractor $extractor = null, OutputInterface $output = null) + public function __construct(?DnsDataExtractor $extractor = null, ?OutputInterface $output = null) { $this->extractor = $extractor ?: new DnsDataExtractor(); $this->output = $output ?: new NullOutput(); } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge): bool { return 'dns-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function solve(AuthorizationChallenge $authorizationChallenge) { $recordName = $this->extractor->getRecordName($authorizationChallenge); @@ -80,9 +70,6 @@ public function solve(AuthorizationChallenge $authorizationChallenge) ); } - /** - * {@inheritdoc} - */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { $recordName = $this->extractor->getRecordName($authorizationChallenge); diff --git a/src/Core/Challenge/Http/FilesystemSolver.php b/src/Core/Challenge/Http/FilesystemSolver.php index 8a4e879d..58a781e5 100644 --- a/src/Core/Challenge/Http/FilesystemSolver.php +++ b/src/Core/Challenge/Http/FilesystemSolver.php @@ -43,7 +43,7 @@ class FilesystemSolver implements SolverInterface, ConfigurableServiceInterface */ private $extractor; - public function __construct(ContainerInterface $filesystemFactoryLocator = null, HttpDataExtractor $extractor = null) + public function __construct(?ContainerInterface $filesystemFactoryLocator = null, ?HttpDataExtractor $extractor = null) { $this->filesystemFactoryLocator = $filesystemFactoryLocator ?: new ServiceLocator([]); $this->extractor = $extractor ?: new HttpDataExtractor(); @@ -59,17 +59,11 @@ public function configure(array $config) $this->filesystem = $factory->create($config); } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge): bool { return 'http-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function solve(AuthorizationChallenge $authorizationChallenge) { $checkPath = $this->extractor->getCheckPath($authorizationChallenge); @@ -78,9 +72,6 @@ public function solve(AuthorizationChallenge $authorizationChallenge) $this->filesystem->write($checkPath, $checkContent); } - /** - * {@inheritdoc} - */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { $checkPath = $this->extractor->getCheckPath($authorizationChallenge); diff --git a/src/Core/Challenge/Http/HttpValidator.php b/src/Core/Challenge/Http/HttpValidator.php index 643572a2..f0933fe6 100644 --- a/src/Core/Challenge/Http/HttpValidator.php +++ b/src/Core/Challenge/Http/HttpValidator.php @@ -34,23 +34,17 @@ class HttpValidator implements ValidatorInterface */ private $client; - public function __construct(HttpDataExtractor $extractor = null, Client $client = null) + public function __construct(?HttpDataExtractor $extractor = null, ?Client $client = null) { $this->extractor = $extractor ?: new HttpDataExtractor(); $this->client = $client ?: new Client(); } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { return 'http-01' === $authorizationChallenge->getType() && !$solver instanceof MockServerHttpSolver; } - /** - * {@inheritdoc} - */ public function isValid(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { $checkUrl = $this->extractor->getCheckUrl($authorizationChallenge); diff --git a/src/Core/Challenge/Http/MockHttpValidator.php b/src/Core/Challenge/Http/MockHttpValidator.php index d3d87ed6..15b2cbea 100644 --- a/src/Core/Challenge/Http/MockHttpValidator.php +++ b/src/Core/Challenge/Http/MockHttpValidator.php @@ -22,17 +22,11 @@ */ class MockHttpValidator implements ValidatorInterface { - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { return 'http-01' === $authorizationChallenge->getType() && $solver instanceof MockServerHttpSolver; } - /** - * {@inheritdoc} - */ public function isValid(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { return true; diff --git a/src/Core/Challenge/Http/MockServerHttpSolver.php b/src/Core/Challenge/Http/MockServerHttpSolver.php index 72c73a2c..4ea416d3 100644 --- a/src/Core/Challenge/Http/MockServerHttpSolver.php +++ b/src/Core/Challenge/Http/MockServerHttpSolver.php @@ -23,17 +23,11 @@ */ class MockServerHttpSolver implements SolverInterface { - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge): bool { return 'http-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function solve(AuthorizationChallenge $authorizationChallenge) { (new Client())->post('http://localhost:8055/add-http01', [ @@ -44,9 +38,6 @@ public function solve(AuthorizationChallenge $authorizationChallenge) ]); } - /** - * {@inheritdoc} - */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { (new Client())->post('http://localhost:8055/del-http01', [ diff --git a/src/Core/Challenge/Http/SimpleHttpSolver.php b/src/Core/Challenge/Http/SimpleHttpSolver.php index 7be53501..b0dea71c 100644 --- a/src/Core/Challenge/Http/SimpleHttpSolver.php +++ b/src/Core/Challenge/Http/SimpleHttpSolver.php @@ -33,23 +33,17 @@ class SimpleHttpSolver implements SolverInterface */ private $output; - public function __construct(HttpDataExtractor $extractor = null, OutputInterface $output = null) + public function __construct(?HttpDataExtractor $extractor = null, ?OutputInterface $output = null) { $this->extractor = $extractor ?: new HttpDataExtractor(); $this->output = $output ?: new NullOutput(); } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge): bool { return 'http-01' === $authorizationChallenge->getType(); } - /** - * {@inheritdoc} - */ public function solve(AuthorizationChallenge $authorizationChallenge) { $checkUrl = $this->extractor->getCheckUrl($authorizationChallenge); @@ -75,9 +69,6 @@ public function solve(AuthorizationChallenge $authorizationChallenge) ); } - /** - * {@inheritdoc} - */ public function cleanup(AuthorizationChallenge $authorizationChallenge) { $checkUrl = $this->extractor->getCheckUrl($authorizationChallenge); diff --git a/src/Core/Challenge/WaitingValidator.php b/src/Core/Challenge/WaitingValidator.php index b2802096..7c6474c2 100644 --- a/src/Core/Challenge/WaitingValidator.php +++ b/src/Core/Challenge/WaitingValidator.php @@ -33,17 +33,11 @@ public function __construct(ValidatorInterface $validator, int $timeout = 180) $this->timeout = $timeout; } - /** - * {@inheritdoc} - */ public function supports(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { return $this->validator->supports($authorizationChallenge, $solver); } - /** - * {@inheritdoc} - */ public function isValid(AuthorizationChallenge $authorizationChallenge, SolverInterface $solver): bool { $limitEndTime = time() + $this->timeout; diff --git a/src/Core/Exception/AcmeCoreClientException.php b/src/Core/Exception/AcmeCoreClientException.php index c452df5f..71a16624 100644 --- a/src/Core/Exception/AcmeCoreClientException.php +++ b/src/Core/Exception/AcmeCoreClientException.php @@ -18,7 +18,7 @@ */ class AcmeCoreClientException extends AcmeCoreException { - public function __construct($message, \Exception $previous = null) + public function __construct($message, ?\Exception $previous = null) { parent::__construct($message, 0, $previous); } diff --git a/src/Core/Exception/AcmeCoreServerException.php b/src/Core/Exception/AcmeCoreServerException.php index 476c3659..f9f88e57 100644 --- a/src/Core/Exception/AcmeCoreServerException.php +++ b/src/Core/Exception/AcmeCoreServerException.php @@ -20,7 +20,7 @@ */ class AcmeCoreServerException extends AcmeCoreException { - public function __construct(RequestInterface $request, $message, \Exception $previous = null) + public function __construct(RequestInterface $request, $message, ?\Exception $previous = null) { parent::__construct($message, $previous ? $previous->getCode() : 0, $previous); } diff --git a/src/Core/Exception/AcmeDnsResolutionException.php b/src/Core/Exception/AcmeDnsResolutionException.php index 8c00aea1..c8340d3f 100644 --- a/src/Core/Exception/AcmeDnsResolutionException.php +++ b/src/Core/Exception/AcmeDnsResolutionException.php @@ -16,7 +16,7 @@ */ class AcmeDnsResolutionException extends AcmeCoreException { - public function __construct($message, \Exception $previous = null) + public function __construct($message, ?\Exception $previous = null) { parent::__construct(null === $message ? 'An exception was thrown during resolution of DNS' : $message, 0, $previous); } diff --git a/src/Core/Exception/Protocol/ChallengeFailedException.php b/src/Core/Exception/Protocol/ChallengeFailedException.php index fb42cdba..dac02348 100644 --- a/src/Core/Exception/Protocol/ChallengeFailedException.php +++ b/src/Core/Exception/Protocol/ChallengeFailedException.php @@ -18,7 +18,7 @@ class ChallengeFailedException extends ProtocolException { private $response; - public function __construct($response, \Exception $previous = null) + public function __construct($response, ?\Exception $previous = null) { parent::__construct( sprintf('Challenge failed (response: %s).', json_encode($response)), diff --git a/src/Core/Exception/Protocol/ChallengeNotSupportedException.php b/src/Core/Exception/Protocol/ChallengeNotSupportedException.php index f60a9bb9..01165824 100644 --- a/src/Core/Exception/Protocol/ChallengeNotSupportedException.php +++ b/src/Core/Exception/Protocol/ChallengeNotSupportedException.php @@ -16,7 +16,7 @@ */ class ChallengeNotSupportedException extends ProtocolException { - public function __construct(\Exception $previous = null) + public function __construct(?\Exception $previous = null) { parent::__construct('This ACME server does not expose supported challenge.', $previous); } diff --git a/src/Core/Exception/Protocol/ChallengeTimedOutException.php b/src/Core/Exception/Protocol/ChallengeTimedOutException.php index ffed7123..aaf0cf0b 100644 --- a/src/Core/Exception/Protocol/ChallengeTimedOutException.php +++ b/src/Core/Exception/Protocol/ChallengeTimedOutException.php @@ -18,7 +18,7 @@ class ChallengeTimedOutException extends ProtocolException { private $response; - public function __construct($response, \Exception $previous = null) + public function __construct($response, ?\Exception $previous = null) { parent::__construct( sprintf('Challenge timed out (response: %s).', json_encode($response)), diff --git a/src/Core/Exception/Server/BadCsrServerException.php b/src/Core/Exception/Server/BadCsrServerException.php index 333e19ea..b3a6a035 100644 --- a/src/Core/Exception/Server/BadCsrServerException.php +++ b/src/Core/Exception/Server/BadCsrServerException.php @@ -19,7 +19,7 @@ */ class BadCsrServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/BadNonceServerException.php b/src/Core/Exception/Server/BadNonceServerException.php index a731ce34..272d276b 100644 --- a/src/Core/Exception/Server/BadNonceServerException.php +++ b/src/Core/Exception/Server/BadNonceServerException.php @@ -19,7 +19,7 @@ */ class BadNonceServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/CaaServerException.php b/src/Core/Exception/Server/CaaServerException.php index 5def4239..abde3db7 100644 --- a/src/Core/Exception/Server/CaaServerException.php +++ b/src/Core/Exception/Server/CaaServerException.php @@ -19,7 +19,7 @@ */ class CaaServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/ConnectionServerException.php b/src/Core/Exception/Server/ConnectionServerException.php index b53e0d9f..841368f7 100644 --- a/src/Core/Exception/Server/ConnectionServerException.php +++ b/src/Core/Exception/Server/ConnectionServerException.php @@ -19,7 +19,7 @@ */ class ConnectionServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/DnsServerException.php b/src/Core/Exception/Server/DnsServerException.php index 16d1b999..05b1cb78 100644 --- a/src/Core/Exception/Server/DnsServerException.php +++ b/src/Core/Exception/Server/DnsServerException.php @@ -19,7 +19,7 @@ */ class DnsServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/IncorrectResponseServerException.php b/src/Core/Exception/Server/IncorrectResponseServerException.php index e6d30612..f528e625 100644 --- a/src/Core/Exception/Server/IncorrectResponseServerException.php +++ b/src/Core/Exception/Server/IncorrectResponseServerException.php @@ -19,7 +19,7 @@ */ class IncorrectResponseServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/InternalServerException.php b/src/Core/Exception/Server/InternalServerException.php index 299c3caa..bfaa9097 100644 --- a/src/Core/Exception/Server/InternalServerException.php +++ b/src/Core/Exception/Server/InternalServerException.php @@ -19,7 +19,7 @@ */ class InternalServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/InvalidContactServerException.php b/src/Core/Exception/Server/InvalidContactServerException.php index 4a736be6..eadb7d3b 100644 --- a/src/Core/Exception/Server/InvalidContactServerException.php +++ b/src/Core/Exception/Server/InvalidContactServerException.php @@ -19,7 +19,7 @@ */ class InvalidContactServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/InvalidEmailServerException.php b/src/Core/Exception/Server/InvalidEmailServerException.php index f1875187..bef0fa74 100644 --- a/src/Core/Exception/Server/InvalidEmailServerException.php +++ b/src/Core/Exception/Server/InvalidEmailServerException.php @@ -19,7 +19,7 @@ */ class InvalidEmailServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/MalformedServerException.php b/src/Core/Exception/Server/MalformedServerException.php index d6a57a08..5358bf54 100644 --- a/src/Core/Exception/Server/MalformedServerException.php +++ b/src/Core/Exception/Server/MalformedServerException.php @@ -19,7 +19,7 @@ */ class MalformedServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/OrderNotReadyServerException.php b/src/Core/Exception/Server/OrderNotReadyServerException.php index 6e6e88c4..9c584284 100644 --- a/src/Core/Exception/Server/OrderNotReadyServerException.php +++ b/src/Core/Exception/Server/OrderNotReadyServerException.php @@ -16,7 +16,7 @@ class OrderNotReadyServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/RateLimitedServerException.php b/src/Core/Exception/Server/RateLimitedServerException.php index 4ff34410..f0190b4f 100644 --- a/src/Core/Exception/Server/RateLimitedServerException.php +++ b/src/Core/Exception/Server/RateLimitedServerException.php @@ -19,7 +19,7 @@ */ class RateLimitedServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/RejectedIdentifierServerException.php b/src/Core/Exception/Server/RejectedIdentifierServerException.php index 7a0d53cd..fa4e1dde 100644 --- a/src/Core/Exception/Server/RejectedIdentifierServerException.php +++ b/src/Core/Exception/Server/RejectedIdentifierServerException.php @@ -19,7 +19,7 @@ */ class RejectedIdentifierServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/TlsServerException.php b/src/Core/Exception/Server/TlsServerException.php index b7d04ed1..45c50d21 100644 --- a/src/Core/Exception/Server/TlsServerException.php +++ b/src/Core/Exception/Server/TlsServerException.php @@ -19,7 +19,7 @@ */ class TlsServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/UnauthorizedServerException.php b/src/Core/Exception/Server/UnauthorizedServerException.php index 367d09f4..c76343b3 100644 --- a/src/Core/Exception/Server/UnauthorizedServerException.php +++ b/src/Core/Exception/Server/UnauthorizedServerException.php @@ -19,7 +19,7 @@ */ class UnauthorizedServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/UnknownHostServerException.php b/src/Core/Exception/Server/UnknownHostServerException.php index 33628c0c..671f366c 100644 --- a/src/Core/Exception/Server/UnknownHostServerException.php +++ b/src/Core/Exception/Server/UnknownHostServerException.php @@ -19,7 +19,7 @@ */ class UnknownHostServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/UnsupportedContactServerException.php b/src/Core/Exception/Server/UnsupportedContactServerException.php index 44c10e7c..e34b4d5e 100644 --- a/src/Core/Exception/Server/UnsupportedContactServerException.php +++ b/src/Core/Exception/Server/UnsupportedContactServerException.php @@ -19,7 +19,7 @@ */ class UnsupportedContactServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/UnsupportedIdentifierServerException.php b/src/Core/Exception/Server/UnsupportedIdentifierServerException.php index cdd189cb..e97db3c4 100644 --- a/src/Core/Exception/Server/UnsupportedIdentifierServerException.php +++ b/src/Core/Exception/Server/UnsupportedIdentifierServerException.php @@ -19,7 +19,7 @@ */ class UnsupportedIdentifierServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Exception/Server/UserActionRequiredServerException.php b/src/Core/Exception/Server/UserActionRequiredServerException.php index b255970b..a457d844 100644 --- a/src/Core/Exception/Server/UserActionRequiredServerException.php +++ b/src/Core/Exception/Server/UserActionRequiredServerException.php @@ -19,7 +19,7 @@ */ class UserActionRequiredServerException extends AcmeCoreServerException { - public function __construct(RequestInterface $request, string $detail, \Exception $previous = null) + public function __construct(RequestInterface $request, string $detail, ?\Exception $previous = null) { parent::__construct( $request, diff --git a/src/Core/Filesystem/Adapter/FlysystemFtpFactory.php b/src/Core/Filesystem/Adapter/FlysystemFtpFactory.php index 7faf42c0..e43b7586 100644 --- a/src/Core/Filesystem/Adapter/FlysystemFtpFactory.php +++ b/src/Core/Filesystem/Adapter/FlysystemFtpFactory.php @@ -18,9 +18,6 @@ class FlysystemFtpFactory implements FilesystemFactoryInterface { - /** - * {@inheritdoc} - */ public function create(array $config): FilesystemInterface { return new FlysystemAdapter(new Filesystem(new Ftp($config))); diff --git a/src/Core/Filesystem/Adapter/FlysystemLocalFactory.php b/src/Core/Filesystem/Adapter/FlysystemLocalFactory.php index a67e874b..6e21ff17 100644 --- a/src/Core/Filesystem/Adapter/FlysystemLocalFactory.php +++ b/src/Core/Filesystem/Adapter/FlysystemLocalFactory.php @@ -19,9 +19,6 @@ class FlysystemLocalFactory implements FilesystemFactoryInterface { - /** - * {@inheritdoc} - */ public function create(array $config): FilesystemInterface { Assert::keyExists($config, 'root', 'create::$config expected an array with the key %s.'); diff --git a/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php b/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php index fd6dd15f..0342adc5 100644 --- a/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php +++ b/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php @@ -18,9 +18,6 @@ class FlysystemSftpFactory implements FilesystemFactoryInterface { - /** - * {@inheritdoc} - */ public function create(array $config): FilesystemInterface { return new FlysystemAdapter(new Filesystem(new SftpAdapter($config))); diff --git a/src/Core/Http/SecureHttpClient.php b/src/Core/Http/SecureHttpClient.php index 6fac9553..127b1811 100644 --- a/src/Core/Http/SecureHttpClient.php +++ b/src/Core/Http/SecureHttpClient.php @@ -157,8 +157,6 @@ public function signJwkPayload(string $endpoint, $payload = null, bool $withNonc /** * Generates an External Account Binding payload signed with JWS. - * - * @param string|array|null $payload */ public function createExternalAccountPayload(ExternalAccount $externalAccount, string $url): array { @@ -189,11 +187,11 @@ public function createExternalAccountPayload(ExternalAccount $externalAccount, s * Send a request encoded in the format defined by the ACME protocol * and its content (optionally parsed as JSON). * + * @return array|string Array of parsed JSON if $returnJson = true, string otherwise + * * @throws AcmeCoreClientException when an error occured during response parsing * @throws ExpectedJsonException when $returnJson = true and the response is not valid JSON * @throws AcmeCoreServerException when the ACME server returns an error HTTP status code - * - * @return array|string Array of parsed JSON if $returnJson = true, string otherwise */ public function request(string $method, string $endpoint, array $data = [], bool $returnJson = true) { @@ -294,7 +292,7 @@ public function getBase64Encoder(): Base64SafeEncoder /** * Sign the given Payload. */ - private function signPayload(array $protected, array $payload = null): array + private function signPayload(array $protected, ?array $payload = null): array { if (!isset($protected['alg'])) { throw new \InvalidArgumentException('The property "alg" is required in the protected array'); @@ -329,7 +327,7 @@ private function signPayload(array $protected, array $payload = null): array private function createRequest($method, $endpoint, $data, $acceptJson) { $request = new Request($method, $endpoint); - + if ($acceptJson) { $request = $request->withHeader('Accept', 'application/json,application/jose+json,'); } else { @@ -390,7 +388,7 @@ private function getAlg(): string return 'ES512'; } - // no break to let the default case + // no break to let the default case default: throw new AcmeCoreClientException('Private key type is not supported'); } diff --git a/src/Core/Http/ServerErrorHandler.php b/src/Core/Http/ServerErrorHandler.php index b161fa70..b9f5301c 100644 --- a/src/Core/Http/ServerErrorHandler.php +++ b/src/Core/Http/ServerErrorHandler.php @@ -93,7 +93,7 @@ public static function getResponseBodySummary(ResponseInterface $response): stri public function createAcmeExceptionForResponse( RequestInterface $request, ResponseInterface $response, - \Exception $previous = null + ?\Exception $previous = null ): AcmeCoreServerException { $body = Utils::copyToString($response->getBody()); @@ -127,7 +127,7 @@ public function createAcmeExceptionForResponse( private function createDefaultExceptionForResponse( RequestInterface $request, ResponseInterface $response, - \Exception $previous = null + ?\Exception $previous = null ): AcmeCoreServerException { return new AcmeCoreServerException( $request, diff --git a/src/Core/Protocol/CertificateOrder.php b/src/Core/Protocol/CertificateOrder.php index 2f7e11ec..48698fea 100644 --- a/src/Core/Protocol/CertificateOrder.php +++ b/src/Core/Protocol/CertificateOrder.php @@ -29,7 +29,7 @@ class CertificateOrder /** @var string */ private $status; - public function __construct(array $authorizationsChallenges, string $orderEndpoint = null, string $status = null) + public function __construct(array $authorizationsChallenges, ?string $orderEndpoint = null, ?string $status = null) { foreach ($authorizationsChallenges as &$authorizationChallenges) { foreach ($authorizationChallenges as &$authorizationChallenge) { diff --git a/src/Core/Util/JsonDecoder.php b/src/Core/Util/JsonDecoder.php index 9b357ac6..a783641c 100644 --- a/src/Core/Util/JsonDecoder.php +++ b/src/Core/Util/JsonDecoder.php @@ -32,8 +32,6 @@ class JsonDecoder * * @throws \InvalidArgumentException if the JSON cannot be decoded * - * @return mixed - * * @see http://www.php.net/manual/en/function.json-decode.php */ public static function decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0) diff --git a/src/Ssl/Certificate.php b/src/Ssl/Certificate.php index 12465bd8..3d12ab5c 100644 --- a/src/Ssl/Certificate.php +++ b/src/Ssl/Certificate.php @@ -27,7 +27,7 @@ class Certificate /** @var Certificate */ private $issuerCertificate; - public function __construct(string $certificatePEM, self $issuerCertificate = null) + public function __construct(string $certificatePEM, ?self $issuerCertificate = null) { Assert::stringNotEmpty($certificatePEM, __CLASS__.'::$certificatePEM should not be an empty string. Got %s'); diff --git a/src/Ssl/DistinguishedName.php b/src/Ssl/DistinguishedName.php index 1136bb61..50de2b61 100644 --- a/src/Ssl/DistinguishedName.php +++ b/src/Ssl/DistinguishedName.php @@ -46,12 +46,12 @@ class DistinguishedName public function __construct( string $commonName, - string $countryName = null, - string $stateOrProvinceName = null, - string $localityName = null, - string $organizationName = null, - string $organizationalUnitName = null, - string $emailAddress = null, + ?string $countryName = null, + ?string $stateOrProvinceName = null, + ?string $localityName = null, + ?string $organizationName = null, + ?string $organizationalUnitName = null, + ?string $emailAddress = null, array $subjectAlternativeNames = [] ) { Assert::stringNotEmpty($commonName, __CLASS__.'::$commonName expected a non empty string. Got: %s'); diff --git a/src/Ssl/Generator/KeyPairGenerator.php b/src/Ssl/Generator/KeyPairGenerator.php index 67d4d56b..328be8bb 100644 --- a/src/Ssl/Generator/KeyPairGenerator.php +++ b/src/Ssl/Generator/KeyPairGenerator.php @@ -29,7 +29,7 @@ class KeyPairGenerator { private $generator; - public function __construct(PrivateKeyGeneratorInterface $generator = null) + public function __construct(?PrivateKeyGeneratorInterface $generator = null) { $this->generator = $generator ?: new ChainPrivateKeyGenerator( [ @@ -46,7 +46,7 @@ public function __construct(PrivateKeyGeneratorInterface $generator = null) * * @throws KeyPairGenerationException when OpenSSL failed to generate keys */ - public function generateKeyPair(KeyOption $keyOption = null): KeyPair + public function generateKeyPair(?KeyOption $keyOption = null): KeyPair { if (null === $keyOption) { $keyOption = new RsaKeyOption(); diff --git a/src/Ssl/ParsedCertificate.php b/src/Ssl/ParsedCertificate.php index f6adea4c..ef8c21a0 100644 --- a/src/Ssl/ParsedCertificate.php +++ b/src/Ssl/ParsedCertificate.php @@ -44,20 +44,14 @@ class ParsedCertificate /** @var array */ private $subjectAlternativeNames; - /** - * @param string $issuer - * @param \DateTime $validFrom - * @param \DateTime $validTo - * @param string $serialNumber - */ public function __construct( Certificate $source, string $subject, - string $issuer = null, + ?string $issuer = null, bool $selfSigned = true, - \DateTime $validFrom = null, - \DateTime $validTo = null, - string $serialNumber = null, + ?\DateTime $validFrom = null, + ?\DateTime $validTo = null, + ?string $serialNumber = null, array $subjectAlternativeNames = [] ) { Assert::stringNotEmpty($subject, __CLASS__.'::$subject expected a non empty string. Got: %s'); diff --git a/src/Ssl/PrivateKey.php b/src/Ssl/PrivateKey.php index c7080035..b4508089 100644 --- a/src/Ssl/PrivateKey.php +++ b/src/Ssl/PrivateKey.php @@ -21,9 +21,6 @@ */ class PrivateKey extends Key { - /** - * {@inheritdoc} - */ public function getResource() { if (!$resource = openssl_pkey_get_private($this->keyPEM)) { diff --git a/src/Ssl/PublicKey.php b/src/Ssl/PublicKey.php index f0a511d2..aa570c62 100644 --- a/src/Ssl/PublicKey.php +++ b/src/Ssl/PublicKey.php @@ -21,9 +21,6 @@ */ class PublicKey extends Key { - /** - * {@inheritdoc} - */ public function getResource() { if (!$resource = openssl_pkey_get_public($this->keyPEM)) { diff --git a/tests/Cli/Repository/RepositoryTest.php b/tests/Cli/Repository/RepositoryTest.php index 8fc69de8..a5074234 100644 --- a/tests/Cli/Repository/RepositoryTest.php +++ b/tests/Cli/Repository/RepositoryTest.php @@ -24,7 +24,6 @@ use League\Flysystem\Memory\MemoryAdapter; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; diff --git a/tests/Ssl/CertificateTest.php b/tests/Ssl/CertificateTest.php index 24b0a4c2..db35a756 100644 --- a/tests/Ssl/CertificateTest.php +++ b/tests/Ssl/CertificateTest.php @@ -22,7 +22,7 @@ class CertificateTest extends TestCase public function testGetPublicKeyReturnsAPublicKey() { $certificate = new Certificate( - ' + ' -----BEGIN CERTIFICATE----- MIIFkTCCBHmgAwIBAgITAP/g3ErooCmPSlx2kAVx9abKkTANBgkqhkiG9w0BAQsF ADAfMR0wGwYDVQQDExRoYXBweSBoYWNrZXIgZmFrZSBDQTAeFw0xNjAzMjUyMjI3 From d3800f19f387bbe73e337ba5fb3ad583ce1ecbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 14:43:00 +0200 Subject: [PATCH 27/77] Sync all version in composer.json + update some lowest constrainsts --- bin/acme | 4 ++-- composer.json | 22 +++++++++++----------- src/Cli/Application.php | 2 +- src/Core/composer.json | 2 +- src/Ssl/composer.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bin/acme b/bin/acme index b9c0dd24..d164e5c9 100755 --- a/bin/acme +++ b/bin/acme @@ -10,8 +10,8 @@ * file that was distributed with this source code. */ -if (version_compare('5.5.0', PHP_VERSION, '>')) { - echo 'This version of Acme PHP requires PHP 5.5.0.'.PHP_EOL; +if (version_compare('8.1.0', PHP_VERSION, '>')) { + echo 'This version of Acme PHP requires PHP 8.1.0.'.PHP_EOL; exit; } diff --git a/composer.json b/composer.json index 6bb0b415..d52d4394 100644 --- a/composer.json +++ b/composer.json @@ -49,26 +49,26 @@ "lcobucci/jwt": "^3.3|^4.0", "league/flysystem": "^1.0.19", "league/flysystem-memory": "^1.0", - "league/flysystem-sftp": "^1.0.7", + "league/flysystem-sftp": "^1.0.22", "monolog/monolog": "^1.19|^2.0", "padraic/phar-updater": "^1.0", "psr/container": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0", - "symfony/config": "^5.4 || ^6.4", - "symfony/console": "^5.4 || ^6.4", - "symfony/dependency-injection": "^5.4 || ^6.4", - "symfony/filesystem": "^5.4 || ^6.4", - "symfony/serializer": "^5.4 || ^6.4", - "symfony/yaml": "^5.4 || ^6.4", + "symfony/config": "^5.4.12 || ^6.4", + "symfony/console": "^5.4.12 || ^6.4", + "symfony/dependency-injection": "^5.4.12 || ^6.4", + "symfony/filesystem": "^5.4.12 || ^6.4", + "symfony/serializer": "^5.4.12 || ^6.4", + "symfony/yaml": "^5.4.12 || ^6.4", "webmozart/assert": "^1.0", "webmozart/path-util": "^2.3" }, "require-dev": { - "symfony/finder": "^5.4 || ^6.4", - "symfony/phpunit-bridge": "^5.4 || ^6.4", - "symfony/property-access": "^5.4 || ^6.4", - "symfony/var-dumper": "^5.4 || ^6.4" + "symfony/finder": "^5.4.12 || ^6.4", + "symfony/phpunit-bridge": "^5.4.12 || ^6.4", + "symfony/property-access": "^5.4.12 || ^6.4", + "symfony/var-dumper": "^5.4.12 || ^6.4" }, "autoload": { "psr-4": { diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 19bb14db..bdb2cf42 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -36,7 +36,7 @@ class Application extends BaseApplication */ public function __construct() { - parent::__construct('Acme PHP - Let\'s Encrypt/ZeroSSL client', '2.0.0'); + parent::__construct('Acme PHP - Let\'s Encrypt/ZeroSSL client', '3.0.0'); } /** diff --git a/src/Core/composer.json b/src/Core/composer.json index 2e82021a..4955887d 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -27,7 +27,7 @@ } ], "require": { - "php": ">=7.2.5", + "php": ">=8.1", "ext-hash": "*", "ext-json": "*", "ext-openssl": "*", diff --git a/src/Ssl/composer.json b/src/Ssl/composer.json index f097d057..da51c8ec 100644 --- a/src/Ssl/composer.json +++ b/src/Ssl/composer.json @@ -32,7 +32,7 @@ } }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "ext-hash": "*", "ext-openssl": "*", "lib-openssl": ">=0.9.8", From 9db6e991c80fd8206ee4ece8e7c3f437116ba497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 15:15:34 +0200 Subject: [PATCH 28/77] Update to flysystem v3 --- composer.json | 6 ++-- src/Cli/Action/FilesystemAction.php | 12 ++++--- src/Cli/Command/StatusCommand.php | 4 +-- src/Cli/Repository/Repository.php | 12 +++---- src/Cli/Resources/services.xml | 2 +- .../Filesystem/Adapter/FlysystemAdapter.php | 32 +++++++++++-------- .../Adapter/FlysystemSftpFactory.php | 17 ++++++++-- src/Core/Filesystem/Adapter/NullAdapter.php | 4 +-- tests/Cli/Repository/RepositoryTest.php | 4 +-- tests/Cli/SftpNginxProxyApplicationTest.php | 25 ++++++++------- 10 files changed, 68 insertions(+), 50 deletions(-) diff --git a/composer.json b/composer.json index d52d4394..b0d8e57e 100644 --- a/composer.json +++ b/composer.json @@ -47,9 +47,9 @@ "guzzlehttp/guzzle": "^7.2", "guzzlehttp/psr7": "^1.0", "lcobucci/jwt": "^3.3|^4.0", - "league/flysystem": "^1.0.19", - "league/flysystem-memory": "^1.0", - "league/flysystem-sftp": "^1.0.22", + "league/flysystem": "^3.10", + "league/flysystem-memory": "^3.10", + "league/flysystem-sftp-v3": "^3.10", "monolog/monolog": "^1.19|^2.0", "padraic/phar-updater": "^1.0", "psr/container": "^1.0", diff --git a/src/Cli/Action/FilesystemAction.php b/src/Cli/Action/FilesystemAction.php index 258b7030..0a8ab45e 100644 --- a/src/Cli/Action/FilesystemAction.php +++ b/src/Cli/Action/FilesystemAction.php @@ -14,7 +14,8 @@ use AcmePhp\Core\Filesystem\FilesystemFactoryInterface; use AcmePhp\Core\Filesystem\FilesystemInterface; use AcmePhp\Ssl\CertificateResponse; -use League\Flysystem\FilesystemInterface as FlysystemFilesystemInterface; +use League\Flysystem\FileAttributes; +use League\Flysystem\FilesystemOperator; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\ServiceLocator; @@ -24,7 +25,7 @@ class FilesystemAction extends AbstractAction { /** - * @var FlysystemFilesystemInterface + * @var FilesystemOperator */ protected $storage; @@ -33,7 +34,7 @@ class FilesystemAction extends AbstractAction */ protected $filesystemFactoryLocator; - public function __construct(FlysystemFilesystemInterface $storage, ?ContainerInterface $locator = null) + public function __construct(FilesystemOperator $storage, ?ContainerInterface $locator = null) { $this->storage = $storage; $this->filesystemFactoryLocator = $locator ?: new ServiceLocator([]); @@ -48,12 +49,13 @@ public function handle(array $config, CertificateResponse $response) $filesystem = $factory->create($config); $files = $this->storage->listContents('.', true); + /** @var FileAttributes $file */ foreach ($files as $file) { - if (0 === strpos($file['basename'], '.')) { + if (str_starts_with(basename($file->path()), '.')) { continue; } - $this->mirror($file['type'], $file['path'], $filesystem); + $this->mirror($file->type(), $file->path(), $filesystem); } } diff --git a/src/Cli/Command/StatusCommand.php b/src/Cli/Command/StatusCommand.php index a54997b3..0838e0c4 100644 --- a/src/Cli/Command/StatusCommand.php +++ b/src/Cli/Command/StatusCommand.php @@ -12,7 +12,7 @@ namespace AcmePhp\Cli\Command; use AcmePhp\Ssl\Parser\CertificateParser; -use League\Flysystem\FilesystemInterface; +use League\Flysystem\FilesystemOperator; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -39,7 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $repository = $this->getRepository(); - /** @var FilesystemInterface $master */ + /** @var FilesystemOperator $master */ $master = $this->getContainer()->get('repository.storage'); /** @var CertificateParser $certificateParser */ diff --git a/src/Cli/Repository/Repository.php b/src/Cli/Repository/Repository.php index fd80e8d2..6bb6bfb3 100644 --- a/src/Cli/Repository/Repository.php +++ b/src/Cli/Repository/Repository.php @@ -21,7 +21,7 @@ use AcmePhp\Ssl\KeyPair; use AcmePhp\Ssl\PrivateKey; use AcmePhp\Ssl\PublicKey; -use League\Flysystem\FilesystemInterface; +use League\Flysystem\FilesystemOperator; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\SerializerInterface; @@ -50,11 +50,11 @@ class Repository implements RepositoryInterface private $serializer; /** - * @var FilesystemInterface + * @var FilesystemOperator */ private $storage; - public function __construct(SerializerInterface $serializer, FilesystemInterface $storage) + public function __construct(SerializerInterface $serializer, FilesystemOperator $storage) { $this->serializer = $serializer; $this->storage = $storage; @@ -291,11 +291,7 @@ public function loadCertificateOrder(array $domains): CertificateOrder public function save(string $path, string $content, string $visibility = self::VISIBILITY_PRIVATE) { - if (!$this->storage->has($path)) { - $this->storage->write($path, $content); - } else { - $this->storage->update($path, $content); - } + $this->storage->write($path, $content); $this->storage->setVisibility($path, $visibility); } diff --git a/src/Cli/Resources/services.xml b/src/Cli/Resources/services.xml index d347e0ca..d939d50b 100644 --- a/src/Cli/Resources/services.xml +++ b/src/Cli/Resources/services.xml @@ -71,7 +71,7 @@ - + %app.storage_directory% diff --git a/src/Core/Filesystem/Adapter/FlysystemAdapter.php b/src/Core/Filesystem/Adapter/FlysystemAdapter.php index ad5cb944..f676d4f5 100644 --- a/src/Core/Filesystem/Adapter/FlysystemAdapter.php +++ b/src/Core/Filesystem/Adapter/FlysystemAdapter.php @@ -12,7 +12,8 @@ namespace AcmePhp\Core\Filesystem\Adapter; use AcmePhp\Core\Filesystem\FilesystemInterface; -use League\Flysystem\FilesystemInterface as FlysystemFilesystemInterface; +use League\Flysystem\FilesystemException; +use League\Flysystem\FilesystemOperator as FlysystemFilesystemInterface; class FlysystemAdapter implements FilesystemInterface { @@ -28,39 +29,42 @@ public function __construct(FlysystemFilesystemInterface $filesystem) public function write(string $path, string $content) { - $isOnRemote = $this->filesystem->has($path); - if ($isOnRemote && !$this->filesystem->update($path, $content)) { - throw $this->createRuntimeException($path, 'updated'); - } - if (!$isOnRemote && !$this->filesystem->write($path, $content)) { - throw $this->createRuntimeException($path, 'created'); + try { + $this->filesystem->write($path, $content); + } catch (FilesystemException $e) { + throw $this->createRuntimeException($path, 'created', $e); } } public function delete(string $path) { $isOnRemote = $this->filesystem->has($path); - if ($isOnRemote && !$this->filesystem->delete($path)) { - throw $this->createRuntimeException($path, 'delete'); + try { + if ($isOnRemote) { + $this->filesystem->delete($path); + } + } catch (FilesystemException $e) { + throw $this->createRuntimeException($path, 'deleted', $e); } } public function createDir(string $path) { - $isOnRemote = $this->filesystem->has($path); - if (!$isOnRemote && !$this->filesystem->createDir($path)) { - throw $this->createRuntimeException($path, 'created'); + try { + $this->filesystem->createDirectory($path); + } catch (FilesystemException $e) { + throw $this->createRuntimeException($path, 'created', $e); } } - private function createRuntimeException(string $path, string $action): \RuntimeException + private function createRuntimeException(string $path, string $action, FilesystemException $e): \RuntimeException { return new \RuntimeException( sprintf( 'File %s could not be %s because: %s', $path, $action, - error_get_last() + $e->getMessage(), ) ); } diff --git a/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php b/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php index 0342adc5..ffd38828 100644 --- a/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php +++ b/src/Core/Filesystem/Adapter/FlysystemSftpFactory.php @@ -14,12 +14,25 @@ use AcmePhp\Core\Filesystem\FilesystemFactoryInterface; use AcmePhp\Core\Filesystem\FilesystemInterface; use League\Flysystem\Filesystem; -use League\Flysystem\Sftp\SftpAdapter; +use League\Flysystem\PhpseclibV3\SftpAdapter; +use League\Flysystem\PhpseclibV3\SftpConnectionProvider; class FlysystemSftpFactory implements FilesystemFactoryInterface { public function create(array $config): FilesystemInterface { - return new FlysystemAdapter(new Filesystem(new SftpAdapter($config))); + return new FlysystemAdapter( + new Filesystem( + new SftpAdapter( + new SftpConnectionProvider( + $config['host'], + $config['username'], + password: $config['password'] ?? null, + port: $config['port'] ?? 22, + ), + $config['root'] ?? '/', + ) + ) + ); } } diff --git a/src/Core/Filesystem/Adapter/NullAdapter.php b/src/Core/Filesystem/Adapter/NullAdapter.php index 169221aa..3f22d45f 100644 --- a/src/Core/Filesystem/Adapter/NullAdapter.php +++ b/src/Core/Filesystem/Adapter/NullAdapter.php @@ -12,12 +12,12 @@ namespace AcmePhp\Core\Filesystem\Adapter; use League\Flysystem\Filesystem; -use League\Flysystem\Memory\MemoryAdapter; +use League\Flysystem\InMemory\InMemoryFilesystemAdapter; class NullAdapter extends FlysystemAdapter { public function __construct() { - parent::__construct(new Filesystem(new MemoryAdapter())); + parent::__construct(new Filesystem(new InMemoryFilesystemAdapter())); } } diff --git a/tests/Cli/Repository/RepositoryTest.php b/tests/Cli/Repository/RepositoryTest.php index a5074234..6ce933d3 100644 --- a/tests/Cli/Repository/RepositoryTest.php +++ b/tests/Cli/Repository/RepositoryTest.php @@ -21,7 +21,7 @@ use AcmePhp\Ssl\PrivateKey; use AcmePhp\Ssl\PublicKey; use League\Flysystem\Filesystem; -use League\Flysystem\Memory\MemoryAdapter; +use League\Flysystem\InMemory\InMemoryFilesystemAdapter; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; @@ -51,7 +51,7 @@ public function setUp(): void [new PemEncoder(), new JsonEncoder()] ); - $this->storage = new Filesystem(new MemoryAdapter()); + $this->storage = new Filesystem(new InMemoryFilesystemAdapter()); $this->repository = new Repository($this->serializer, $this->storage); } diff --git a/tests/Cli/SftpNginxProxyApplicationTest.php b/tests/Cli/SftpNginxProxyApplicationTest.php index a2754462..6a6b8154 100644 --- a/tests/Cli/SftpNginxProxyApplicationTest.php +++ b/tests/Cli/SftpNginxProxyApplicationTest.php @@ -12,7 +12,8 @@ namespace Tests\AcmePhp\Cli; use League\Flysystem\Filesystem; -use League\Flysystem\Sftp\SftpAdapter; +use League\Flysystem\PhpseclibV3\SftpAdapter; +use League\Flysystem\PhpseclibV3\SftpConnectionProvider; class SftpNginxProxyApplicationTest extends AbstractApplicationTest { @@ -32,18 +33,20 @@ protected function getConfigDir(): string public function testFullProcess() { - $sftpFilesystem = new Filesystem(new SftpAdapter([ - 'host' => 'localhost', - 'port' => 8022, - 'username' => 'acmephp', - 'password' => 'acmephp', - 'root' => '/share', - ])); + $sftpFilesystem = new Filesystem(new SftpAdapter( + new SftpConnectionProvider( + host: 'localhost', + port: 8022, + username: 'acmephp', + password: 'acmephp', + ), + '/share', + )); // Remove any old version of the files - $sftpFilesystem->has('private') && $sftpFilesystem->deleteDir('private'); - $sftpFilesystem->has('certs') && $sftpFilesystem->deleteDir('certs'); - $sftpFilesystem->has('nginxproxy') && $sftpFilesystem->deleteDir('nginxproxy'); + $sftpFilesystem->has('private') && $sftpFilesystem->deleteDirectory('private'); + $sftpFilesystem->has('certs') && $sftpFilesystem->deleteDirectory('certs'); + $sftpFilesystem->has('nginxproxy') && $sftpFilesystem->deleteDirectory('nginxproxy'); // Run the original full process parent::testFullProcess(); From 338b0865017e1560ff04306db1695ecc6e3e4ff9 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Mon, 18 Mar 2024 08:51:01 +0100 Subject: [PATCH 29/77] fix: update self-update command and phar generation config --- box.json.dist | 10 +- composer.json | 2 +- src/Cli/Application.php | 7 +- src/Cli/Command/SelfUpdateCommand.php | 335 -------------------------- 4 files changed, 8 insertions(+), 346 deletions(-) delete mode 100644 src/Cli/Command/SelfUpdateCommand.php diff --git a/box.json.dist b/box.json.dist index a3a93ac7..f477b50c 100644 --- a/box.json.dist +++ b/box.json.dist @@ -3,7 +3,7 @@ "files": [ "LICENSE" ], "finder": [ { - "name": "*.php", + "name": "{\\.(php|bash|fish|zsh)}", "exclude": [ "Tester", "Tests", @@ -16,12 +16,8 @@ "in": "vendor" } ], - "compactors": [ "KevinGH\\Box\\Compactor\\Php" ], - "check-requirements": false, + "git": "git", "compression": "GZ", "git-version": "package_version", - "main": "bin/acme", - "output": "build/acmephp.phar", - "algorithm": "OPENSSL", - "key": "../private.key" + "output": "build/acmephp.phar" } diff --git a/composer.json b/composer.json index d52d4394..6e20d12a 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,7 @@ "alibabacloud/cdn": "^1.7", "alibabacloud/wafopenapi": "^1.7", "aws/aws-sdk-php": "^3.38", + "consolidation/self-update": "^2.2", "guzzlehttp/guzzle": "^7.2", "guzzlehttp/psr7": "^1.0", "lcobucci/jwt": "^3.3|^4.0", @@ -51,7 +52,6 @@ "league/flysystem-memory": "^1.0", "league/flysystem-sftp": "^1.0.22", "monolog/monolog": "^1.19|^2.0", - "padraic/phar-updater": "^1.0", "psr/container": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0", diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 2dc1171f..40ad7724 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -14,8 +14,8 @@ use AcmePhp\Cli\Command\Helper\DistinguishedNameHelper; use AcmePhp\Cli\Command\RevokeCommand; use AcmePhp\Cli\Command\RunCommand; -use AcmePhp\Cli\Command\SelfUpdateCommand; use AcmePhp\Cli\Command\StatusCommand; +use SelfUpdate\SelfUpdateCommand; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Helper\HelperSet; use Webmozart\PathUtil\Path; @@ -33,7 +33,8 @@ class Application extends BaseApplication public function __construct() { - parent::__construct('Acme PHP - Let\'s Encrypt/ZeroSSL client', '3.0.0'); + // This is replaced by humbug/box with a string that looks like this: x.y.z@tag + parent::__construct('Acme PHP - Let\'s Encrypt/ZeroSSL client', '@git@'); } protected function getDefaultCommands(): array @@ -42,7 +43,7 @@ protected function getDefaultCommands(): array new RunCommand(), new RevokeCommand(), new StatusCommand(), - new SelfUpdateCommand(), + new SelfUpdateCommand($this->getName(), explode('@', $this->getVersion())[0], 'acmephp/acmephp'), ]); } diff --git a/src/Cli/Command/SelfUpdateCommand.php b/src/Cli/Command/SelfUpdateCommand.php deleted file mode 100644 index 8e6024d9..00000000 --- a/src/Cli/Command/SelfUpdateCommand.php +++ /dev/null @@ -1,335 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace AcmePhp\Cli\Command; - -use Humbug\SelfUpdate\Strategy\GithubStrategy; -use Humbug\SelfUpdate\Strategy\ShaStrategy; -use Humbug\SelfUpdate\Updater; -use Humbug\SelfUpdate\VersionParser; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * Self-update command. - * - * Heavily inspired from https://github.com/padraic/phar-updater. - * - * @author Titouan Galopin - */ -class SelfUpdateCommand extends Command -{ - public const PACKAGE_NAME = 'acmephp/acmephp'; - public const FILE_NAME = 'acmephp.phar'; - public const VERSION_URL = 'https://acmephp.github.io/downloads/acmephp.version'; - public const PHAR_URL = 'https://acmephp.github.io/downloads/acmephp.phar'; - - /** - * @var string - */ - protected $version; - - /** - * @var OutputInterface - */ - protected $output; - - protected function configure() - { - $this - ->setName('self-update') - ->setDescription('Update acmephp.phar to most recent stable, pre-release or development build.') - ->addOption( - 'dev', - 'd', - InputOption::VALUE_NONE, - 'Update to most recent development build of Acme PHP.' - ) - ->addOption( - 'non-dev', - 'N', - InputOption::VALUE_NONE, - 'Update to most recent non-development (alpha/beta/stable) build of Acme PHP tagged on Github.' - ) - ->addOption( - 'pre', - 'p', - InputOption::VALUE_NONE, - 'Update to most recent pre-release version of Acme PHP (alpha/beta/rc) tagged on Github.' - ) - ->addOption( - 'stable', - 's', - InputOption::VALUE_NONE, - 'Update to most recent stable version tagged on Github.' - ) - ->addOption( - 'rollback', - 'r', - InputOption::VALUE_NONE, - 'Rollback to previous version of Acme PHP if available on filesystem.' - ) - ->addOption( - 'check', - 'c', - InputOption::VALUE_NONE, - 'Checks what updates are available across all possible stability tracks.' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $this->output = $output; - $this->version = $this->getApplication()->getVersion(); - $parser = new VersionParser(); - - /* - * Check for ancilliary options - */ - if ($input->getOption('rollback')) { - $this->rollback(); - - return 0; - } - - if ($input->getOption('check')) { - $this->printAvailableUpdates(); - - return 0; - } - - /* - * Update to any specified stability option - */ - if ($input->getOption('dev')) { - $this->updateToDevelopmentBuild(); - - return 0; - } - - if ($input->getOption('pre')) { - $this->updateToPreReleaseBuild(); - - return 0; - } - - if ($input->getOption('stable')) { - $this->updateToStableBuild(); - - return 0; - } - - if ($input->getOption('non-dev')) { - $this->updateToMostRecentNonDevRemote(); - - return 0; - } - - /* - * If current build is stable, only update to more recent stable - * versions if available. User may specify otherwise using options. - */ - if ($parser->isStable($this->version)) { - $this->updateToStableBuild(); - - return 0; - } - - /* - * By default, update to most recent remote version regardless - * of stability. - */ - $this->updateToMostRecentNonDevRemote(); - - return 0; - } - - protected function getStableUpdater() - { - $updater = new Updater(); - $updater->setStrategy(Updater::STRATEGY_GITHUB); - - return $this->getGithubReleasesUpdater($updater); - } - - protected function getPreReleaseUpdater() - { - $updater = new Updater(); - $updater->setStrategy(Updater::STRATEGY_GITHUB); - $updater->getStrategy()->setStability(GithubStrategy::UNSTABLE); - - return $this->getGithubReleasesUpdater($updater); - } - - protected function getMostRecentNonDevUpdater() - { - $updater = new Updater(); - $updater->setStrategy(Updater::STRATEGY_GITHUB); - $updater->getStrategy()->setStability(GithubStrategy::ANY); - - return $this->getGithubReleasesUpdater($updater); - } - - protected function getGithubReleasesUpdater(Updater $updater) - { - $updater->getStrategy()->setPackageName(self::PACKAGE_NAME); - $updater->getStrategy()->setPharName(self::FILE_NAME); - $updater->getStrategy()->setCurrentLocalVersion($this->version); - - return $updater; - } - - protected function getDevelopmentUpdater() - { - $updater = new Updater(); - $updater->getStrategy()->setPharUrl(self::PHAR_URL); - $updater->getStrategy()->setVersionUrl(self::VERSION_URL); - - return $updater; - } - - protected function updateToStableBuild() - { - $this->update($this->getStableUpdater()); - } - - protected function updateToPreReleaseBuild() - { - $this->update($this->getPreReleaseUpdater()); - } - - protected function updateToMostRecentNonDevRemote() - { - $this->update($this->getMostRecentNonDevUpdater()); - } - - protected function updateToDevelopmentBuild() - { - $this->update($this->getDevelopmentUpdater()); - } - - protected function update(Updater $updater) - { - $this->output->writeln('Updating...'.PHP_EOL); - - try { - $result = $updater->update(); - - $newVersion = $updater->getNewVersion(); - $oldVersion = $updater->getOldVersion(); - if (40 === \strlen($newVersion)) { - $newVersion = 'dev-'.$newVersion; - } - if (40 === \strlen($oldVersion)) { - $oldVersion = 'dev-'.$oldVersion; - } - - if ($result) { - $this->output->writeln('Acme PHP has been updated.'); - $this->output->writeln(sprintf( - 'Current version is: %s.', - $newVersion - )); - $this->output->writeln(sprintf( - 'Previous version was: %s.', - $oldVersion - )); - } else { - $this->output->writeln('Acme PHP is currently up to date.'); - $this->output->writeln(sprintf( - 'Current version is: %s.', - $oldVersion - )); - } - } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); - } - $this->output->write(PHP_EOL); - $this->output->writeln('You can also select update stability using --dev, --pre (alpha/beta/rc) or --stable.'); - } - - protected function rollback() - { - $updater = new Updater(); - - try { - $result = $updater->rollback(); - if ($result) { - $this->output->writeln('Acme PHP has been rolled back to prior version.'); - } else { - $this->output->writeln('Rollback failed for reasons unknown.'); - } - } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); - } - } - - protected function printAvailableUpdates() - { - $this->printCurrentLocalVersion(); - $this->printCurrentStableVersion(); - $this->printCurrentPreReleaseVersion(); - $this->printCurrentDevVersion(); - $this->output->writeln('You can select update stability using --dev, --pre or --stable when self-updating.'); - } - - protected function printCurrentLocalVersion() - { - $this->output->writeln(sprintf( - 'Your current local build version is: %s', - $this->version - )); - } - - protected function printCurrentStableVersion() - { - $this->printVersion($this->getStableUpdater()); - } - - protected function printCurrentPreReleaseVersion() - { - $this->printVersion($this->getPreReleaseUpdater()); - } - - protected function printCurrentDevVersion() - { - $this->printVersion($this->getDevelopmentUpdater()); - } - - protected function printVersion(Updater $updater) - { - $stability = 'stable'; - if ($updater->getStrategy() instanceof ShaStrategy) { - $stability = 'development'; - } elseif ($updater->getStrategy() instanceof GithubStrategy - && GithubStrategy::UNSTABLE === $updater->getStrategy()->getStability()) { - $stability = 'pre-release'; - } - - try { - if ($updater->hasUpdate()) { - $this->output->writeln(sprintf( - 'The current %s build available remotely is: %s', - $stability, - $updater->getNewVersion() - )); - } elseif (false === $updater->getNewVersion()) { - $this->output->writeln(sprintf('There are no %s builds available.', $stability)); - } else { - $this->output->writeln(sprintf('You have the current %s build installed.', $stability)); - } - } catch (\Exception $e) { - $this->output->writeln(sprintf('Error: %s', $e->getMessage())); - } - } -} From 5c1c7940b59fcaa971ffd1f014f803c0c3f8dd5f Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Wed, 14 Aug 2024 15:21:31 +0200 Subject: [PATCH 30/77] chore: fix cs --- src/Cli/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 40ad7724..1224cced 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -43,7 +43,7 @@ protected function getDefaultCommands(): array new RunCommand(), new RevokeCommand(), new StatusCommand(), - new SelfUpdateCommand($this->getName(), explode('@', $this->getVersion())[0], 'acmephp/acmephp'), + new SelfUpdateCommand($this->getName(), explode('@', $this->getVersion())[0], 'acmephp/acmephp'), ]); } From 9ab7e1b6eb2b9eb4140cf5ef9487dcf9bcdb0728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 15:28:27 +0200 Subject: [PATCH 31/77] Setup PHPStan --- .github/workflows/test-build.yaml | 21 +- CHANGELOG.md | 8 + composer.json | 1 + phpstan-baseline.neon | 536 ++++++++++++++++++++++++++++++ phpstan.neon | 17 + 5 files changed, 581 insertions(+), 2 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 38b8644b..4e9799db 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -8,12 +8,12 @@ on: jobs: php-cs: + name: PHP-CS-Fixer runs-on: ubuntu-latest steps: - uses: shivammathur/setup-php@v2 with: - php-version: '8.1' - coverage: none + php-version: '8.3' - uses: actions/checkout@master @@ -23,6 +23,23 @@ jobs: - name: Check coding style run: php php-cs-fixer.phar fix --dry-run --diff + phpstan: + name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} + runs-on: ubuntu-latest + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + + - uses: actions/checkout@v4 + + - name: Install Composer dependencies + run: | + composer update --prefer-dist --no-interaction + + - name: Run PHPStan + run: vendor/bin/phpstan analyse + ci: name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index ed010da4..64e0b869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,16 @@ > [!NOTE] > From now on, a particular attention will be given to provide a nice changelog. +### BC Break + * Drop support for PHP <8.1 * Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 +* Upgrade from FlySystem v1 to v3 + +### Internal + +* Update PHP-CS-Fixer to 3.62.0 +* Analyse code with PHPStan ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements diff --git a/composer.json b/composer.json index b0d8e57e..3e91c0ed 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { + "phpstan/phpstan": "^1.11", "symfony/finder": "^5.4.12 || ^6.4", "symfony/phpunit-bridge": "^5.4.12 || ^6.4", "symfony/property-access": "^5.4.12 || ^6.4", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..1b309a64 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,536 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined method AlibabaCloud\\\\WafOpenapi\\\\V20161111\\\\UpgradeInstance\\:\\:withCert\\(\\)\\.$#" + count: 1 + path: src/Cli/Action/InstallAliyunWafAction.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Console\\\\Application\\:\\:getStorageDirectory\\(\\)\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Call to an undefined method object\\:\\:createSecureHttpClient\\(\\)\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:alert\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:critical\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:debug\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:emergency\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:error\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:getCliLogger\\(\\) should return Psr\\\\Log\\\\LoggerInterface but returns object\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:getRepository\\(\\) should return AcmePhp\\\\Cli\\\\Repository\\\\RepositoryInterface but returns object\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:info\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:log\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:notice\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:warning\\(\\) with return type void returns null but should not return anything\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:alert\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:critical\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:debug\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:emergency\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:error\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:info\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:log\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:notice\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:warning\\(\\) \\(void\\) is used\\.$#" + count: 1 + path: src/Cli/Command/AbstractCommand.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\RevokeCommand\\:\\:execute\\(\\) should return int but empty return statement found\\.$#" + count: 3 + path: src/Cli/Command/RevokeCommand.php + + - + message: "#^Access to an undefined property object\\:\\:\\$eab_hmac_key\\.$#" + count: 2 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Access to an undefined property object\\:\\:\\$eab_kid\\.$#" + count: 2 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Call to an undefined method object\\:\\:generateKeyPair\\(\\)\\.$#" + count: 2 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Call to an undefined method object\\:\\:get\\(\\)\\.$#" + count: 1 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Call to an undefined method object\\:\\:parse\\(\\)\\.$#" + count: 2 + path: src/Cli/Command/RunCommand.php + + - + message: "#^PHPDoc tag @var for variable \\$solverLocator contains generic class Symfony\\\\Component\\\\DependencyInjection\\\\ServiceLocator but does not specify its types\\: T$#" + count: 1 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Parameter \\#1 \\$input of static method Symfony\\\\Component\\\\Yaml\\\\Yaml\\:\\:parse\\(\\) expects string, string\\|false given\\.$#" + count: 1 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Parameter \\#2 \\$basePath of static method Webmozart\\\\PathUtil\\\\Path\\:\\:makeAbsolute\\(\\) expects string, string\\|false given\\.$#" + count: 1 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Property AcmePhp\\\\Cli\\\\Command\\\\RunCommand\\:\\:\\$config has no type specified\\.$#" + count: 1 + path: src/Cli/Command/RunCommand.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" + count: 5 + path: src/Cli/Configuration/DomainConfiguration.php + + - + message: "#^Class Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder constructor invoked with 0 parameters, 1\\-3 required\\.$#" + count: 4 + path: src/Cli/Configuration/DomainConfiguration.php + + - + message: "#^Parameter \\#1 \\$string of function sha1 expects string, string\\|false given\\.$#" + count: 1 + path: src/Cli/Repository/Repository.php + + - + message: "#^Method AcmePhp\\\\Cli\\\\Serializer\\\\PemNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" + count: 1 + path: src/Cli/Serializer/PemNormalizer.php + + - + message: "#^Method AcmePhp\\\\Core\\\\AcmeClient\\:\\:registerAccount\\(\\) should return array but returns array\\|string\\.$#" + count: 1 + path: src/Core/AcmeClient.php + + - + message: "#^Negated boolean expression is always false\\.$#" + count: 2 + path: src/Core/AcmeClient.php + + - + message: "#^Offset 'challenges' does not exist on array\\|string\\.$#" + count: 2 + path: src/Core/AcmeClient.php + + - + message: "#^Offset 'finalize' does not exist on array\\|string\\.$#" + count: 2 + path: src/Core/AcmeClient.php + + - + message: "#^Offset 'identifier' does not exist on array\\|string\\.$#" + count: 2 + path: src/Core/AcmeClient.php + + - + message: "#^Offset 'status' does not exist on array\\|string\\.$#" + count: 2 + path: src/Core/AcmeClient.php + + - + message: "#^Parameter \\#1 \\$certificate of function openssl_x509_export expects OpenSSLCertificate\\|string, OpenSSLCertificate\\|false given\\.$#" + count: 1 + path: src/Core/AcmeClient.php + + - + message: "#^Parameter \\#1 \\$serverResources of class AcmePhp\\\\Core\\\\Protocol\\\\ResourcesDirectory constructor expects array, array\\|string given\\.$#" + count: 1 + path: src/Core/AcmeClient.php + + - + message: "#^Parameter \\#1 \\$string of function trim expects string, array\\\\|string given\\.$#" + count: 1 + path: src/Core/AcmeClient.php + + - + message: "#^Parameter \\#2 \\$certificate of method AcmePhp\\\\Core\\\\AcmeClient\\:\\:createCertificateResponse\\(\\) expects string, array\\|string given\\.$#" + count: 1 + path: src/Core/AcmeClient.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\GandiSolver\\:\\:\\$cacheZones is unused\\.$#" + count: 1 + path: src/Core/Challenge/Dns/GandiSolver.php + + - + message: "#^Access to constant NS on an unknown class LibDNS\\\\Records\\\\ResourceTypes\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Access to constant QUERY on an unknown class LibDNS\\\\Messages\\\\MessageTypes\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Access to constant TXT on an unknown class LibDNS\\\\Records\\\\ResourceTypes\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Call to method create\\(\\) on an unknown class LibDNS\\\\Decoder\\\\DecoderFactory\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Call to method create\\(\\) on an unknown class LibDNS\\\\Encoder\\\\EncoderFactory\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Call to method create\\(\\) on an unknown class LibDNS\\\\Messages\\\\MessageFactory\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Call to method create\\(\\) on an unknown class LibDNS\\\\Records\\\\QuestionFactory\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Call to method decode\\(\\) on an unknown class LibDNS\\\\Decoder\\\\Decoder\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Call to method encode\\(\\) on an unknown class LibDNS\\\\Encoder\\\\Encoder\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Instantiated class LibDNS\\\\Decoder\\\\DecoderFactory not found\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Instantiated class LibDNS\\\\Encoder\\\\EncoderFactory not found\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Instantiated class LibDNS\\\\Messages\\\\MessageFactory not found\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Instantiated class LibDNS\\\\Records\\\\QuestionFactory not found\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\#1 \\$json of function json_decode expects string, int\\|string given\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\#1 \\$read of function stream_select expects TRead of array\\\\|null, array\\ given\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\#1 \\$socket of function stream_socket_sendto expects resource, resource\\|false given\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\#1 \\$stream of function fread expects resource, resource\\|false given\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\$decoder of method AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:__construct\\(\\) has invalid type LibDNS\\\\Decoder\\\\Decoder\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\$encoder of method AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:__construct\\(\\) has invalid type LibDNS\\\\Encoder\\\\Encoder\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\$messageFactory of method AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:__construct\\(\\) has invalid type LibDNS\\\\Messages\\\\MessageFactory\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\$questionFactory of method AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:__construct\\(\\) has invalid type LibDNS\\\\Records\\\\QuestionFactory\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:\\$decoder has unknown class LibDNS\\\\Decoder\\\\Decoder as its type\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:\\$encoder has unknown class LibDNS\\\\Encoder\\\\Encoder as its type\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:\\$messageFactory has unknown class LibDNS\\\\Messages\\\\MessageFactory as its type\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Challenge\\\\Dns\\\\LibDnsResolver\\:\\:\\$questionFactory has unknown class LibDNS\\\\Records\\\\QuestionFactory as its type\\.$#" + count: 1 + path: src/Core/Challenge/Dns/LibDnsResolver.php + + - + message: "#^Parameter \\#1 \\$string of function addslashes expects string, int\\|string\\|false given\\.$#" + count: 1 + path: src/Core/Challenge/Dns/Route53Solver.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: src/Core/Challenge/Dns/SimpleDnsResolver.php + + - + message: "#^Constructor of class AcmePhp\\\\Core\\\\Exception\\\\AcmeCoreServerException has an unused parameter \\$request\\.$#" + count: 1 + path: src/Core/Exception/AcmeCoreServerException.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Exception\\\\Protocol\\\\ChallengeFailedException\\:\\:\\$response has no type specified\\.$#" + count: 1 + path: src/Core/Exception/Protocol/ChallengeFailedException.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Exception\\\\Protocol\\\\ChallengeTimedOutException\\:\\:\\$response has no type specified\\.$#" + count: 1 + path: src/Core/Exception/Protocol/ChallengeTimedOutException.php + + - + message: "#^Instantiated class League\\\\Flysystem\\\\Adapter\\\\Ftp not found\\.$#" + count: 1 + path: src/Core/Filesystem/Adapter/FlysystemFtpFactory.php + + - + message: "#^Parameter \\#1 \\$adapter of class League\\\\Flysystem\\\\Filesystem constructor expects League\\\\Flysystem\\\\FilesystemAdapter, League\\\\Flysystem\\\\Adapter\\\\Ftp given\\.$#" + count: 1 + path: src/Core/Filesystem/Adapter/FlysystemFtpFactory.php + + - + message: "#^Instantiated class League\\\\Flysystem\\\\Adapter\\\\Local not found\\.$#" + count: 1 + path: src/Core/Filesystem/Adapter/FlysystemLocalFactory.php + + - + message: "#^Parameter \\#1 \\$adapter of class League\\\\Flysystem\\\\Filesystem constructor expects League\\\\Flysystem\\\\FilesystemAdapter, League\\\\Flysystem\\\\Adapter\\\\Local given\\.$#" + count: 1 + path: src/Core/Filesystem/Adapter/FlysystemLocalFactory.php + + - + message: "#^Call to an undefined method Lcobucci\\\\JWT\\\\Signer\\\\Hmac\\\\Sha256\\:\\:getAlgorithmId\\(\\)\\.$#" + count: 1 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Left side of && is always true\\.$#" + count: 1 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Parameter \\#1 \\$contents of static method Lcobucci\\\\JWT\\\\Signer\\\\Key\\\\InMemory\\:\\:plainText\\(\\) expects non\\-empty\\-string, string given\\.$#" + count: 1 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Parameter \\#1 \\$input of method AcmePhp\\\\Core\\\\Http\\\\Base64SafeEncoder\\:\\:encode\\(\\) expects string, string\\|false given\\.$#" + count: 4 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Parameter \\#2 \\$data of function hash expects string, string\\|false given\\.$#" + count: 1 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Parameter \\#2 \\$key of method Lcobucci\\\\JWT\\\\Signer\\\\Hmac\\:\\:sign\\(\\) expects Lcobucci\\\\JWT\\\\Signer\\\\Key, Lcobucci\\\\JWT\\\\Signer\\\\Key\\\\InMemory\\|string given\\.$#" + count: 1 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Parameter \\#2 \\$payload of method AcmePhp\\\\Core\\\\Http\\\\SecureHttpClient\\:\\:signPayload\\(\\) expects array\\|null, array\\|string\\|null given\\.$#" + count: 2 + path: src/Core/Http/SecureHttpClient.php + + - + message: "#^Method AcmePhp\\\\Core\\\\Http\\\\ServerErrorHandler\\:\\:createAcmeExceptionForResponse\\(\\) should return AcmePhp\\\\Core\\\\Exception\\\\AcmeCoreServerException but returns object\\.$#" + count: 1 + path: src/Core/Http/ServerErrorHandler.php + + - + message: "#^Property AcmePhp\\\\Core\\\\Http\\\\ServerErrorHandler\\:\\:\\$exceptions has no type specified\\.$#" + count: 1 + path: src/Core/Http/ServerErrorHandler.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/Core/Protocol/RevocationReason.php + + - + message: "#^Parameter \\#3 \\$depth of function json_decode expects int\\<1, max\\>, int given\\.$#" + count: 1 + path: src/Core/Util/JsonDecoder.php + + - + message: "#^Cannot access offset 'key' on array\\|false\\.$#" + count: 1 + path: src/Ssl/Certificate.php + + - + message: "#^Method AcmePhp\\\\Ssl\\\\Certificate\\:\\:getPublicKeyResource\\(\\) should return resource but returns OpenSSLAsymmetricKey\\.$#" + count: 1 + path: src/Ssl/Certificate.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, resource given\\.$#" + count: 1 + path: src/Ssl/Certificate.php + + - + message: "#^Property AcmePhp\\\\Ssl\\\\Generator\\\\ChainPrivateKeyGenerator\\:\\:\\$generators \\(array\\\\) does not accept iterable\\\\.$#" + count: 1 + path: src/Ssl/Generator/ChainPrivateKeyGenerator.php + + - + message: "#^Parameter \\#2 \\$values of static method Webmozart\\\\Assert\\\\Assert\\:\\:oneOf\\(\\) expects array, array\\\\|false given\\.$#" + count: 1 + path: src/Ssl/Generator/EcKey/EcKeyOption.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_free_key expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: src/Ssl/Parser/KeyParser.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: src/Ssl/Parser/KeyParser.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_free_key expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: src/Ssl/PrivateKey.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_pkey_get_details expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: src/Ssl/PrivateKey.php + + - + message: "#^Cannot access offset 1 on array\\|false\\.$#" + count: 1 + path: src/Ssl/Signer/DataSigner.php + + - + message: "#^Parameter \\#1 \\$key of function openssl_free_key expects OpenSSLAsymmetricKey, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: src/Ssl/Signer/DataSigner.php + + - + message: "#^Parameter \\#2 \\$start of function mb_substr expects int, float\\|int given\\.$#" + count: 1 + path: src/Ssl/Signer/DataSigner.php + + - + message: "#^Parameter \\#3 \\$length of function mb_substr expects int\\|null, float\\|int given\\.$#" + count: 2 + path: src/Ssl/Signer/DataSigner.php + + - + message: "#^Parameter \\#3 \\$private_key of function openssl_sign expects array\\|OpenSSLAsymmetricKey\\|OpenSSLCertificate\\|string, OpenSSLAsymmetricKey\\|resource given\\.$#" + count: 1 + path: src/Ssl/Signer/DataSigner.php diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000..03a0bac5 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,17 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 7 + paths: + - src + + inferPrivatePropertyTypeFromConstructor: true + + ignoreErrors: + - + identifier: missingType.return + - + identifier: missingType.iterableValue + - + identifier: missingType.parameter From ef358f17e04a4b371b1596b4b851b865a98e2b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 15:47:48 +0200 Subject: [PATCH 32/77] Drop support for lcobucci/jwt < 4.1 + Add support for ^5.3 --- CHANGELOG.md | 12 ++++++++++++ composer.json | 2 +- src/Core/Http/SecureHttpClient.php | 2 +- tests/Core/Http/SecureHttpClientTest.php | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed010da4..d981552e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,20 @@ > [!NOTE] > From now on, a particular attention will be given to provide a nice changelog. +### Features + +* Add support for lcobucci/jwt ^5.3 + +### BC Break + * Drop support for PHP <8.1 * Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 +* Drop support for lcobucci/jwt < 4.1 +* Upgrade from FlySystem v1 to v3 + +### Internal + +* Update PHP-CS-Fixer to 3.62.0 ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements diff --git a/composer.json b/composer.json index b0d8e57e..ae40803c 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "aws/aws-sdk-php": "^3.38", "guzzlehttp/guzzle": "^7.2", "guzzlehttp/psr7": "^1.0", - "lcobucci/jwt": "^3.3|^4.0", + "lcobucci/jwt": "^4.1 || ^5.3", "league/flysystem": "^3.10", "league/flysystem-memory": "^3.10", "league/flysystem-sftp-v3": "^3.10", diff --git a/src/Core/Http/SecureHttpClient.php b/src/Core/Http/SecureHttpClient.php index 127b1811..4172f1bf 100644 --- a/src/Core/Http/SecureHttpClient.php +++ b/src/Core/Http/SecureHttpClient.php @@ -163,7 +163,7 @@ public function createExternalAccountPayload(ExternalAccount $externalAccount, s $signer = new Sha256(); $protected = [ - 'alg' => method_exists($signer, 'algorithmId') ? $signer->algorithmId() : $signer->getAlgorithmId(), + 'alg' => $signer->algorithmId(), 'kid' => $externalAccount->getId(), 'url' => $url, ]; diff --git a/tests/Core/Http/SecureHttpClientTest.php b/tests/Core/Http/SecureHttpClientTest.php index 649bc9da..3902a990 100644 --- a/tests/Core/Http/SecureHttpClientTest.php +++ b/tests/Core/Http/SecureHttpClientTest.php @@ -15,6 +15,7 @@ use AcmePhp\Core\Http\Base64SafeEncoder; use AcmePhp\Core\Http\SecureHttpClient; use AcmePhp\Core\Http\ServerErrorHandler; +use AcmePhp\Core\Protocol\ExternalAccount; use AcmePhp\Ssl\Generator\KeyPairGenerator; use AcmePhp\Ssl\Parser\KeyParser; use AcmePhp\Ssl\Signer\DataSigner; @@ -142,6 +143,27 @@ public function testInvalidJsonRequest() $client->request('GET', '/foo', ['foo' => 'bar'], true); } + public function testCreateExternalAccountPayload(): void + { + $client = new SecureHttpClient( + (new KeyPairGenerator())->generateKeyPair(), + new Client(), + new Base64SafeEncoder(), + new KeyParser(), + new DataSigner(), + new ServerErrorHandler(), + ); + + $payload = $client->createExternalAccountPayload(new ExternalAccount('id', str_repeat('hmacKey', '100')), 'bar'); + + $this->assertArrayHasKey('protected', $payload); + $this->assertSame('eyJhbGciOiJIUzI1NiIsImtpZCI6ImlkIiwidXJsIjoiYmFyIn0', $payload['protected']); + $this->assertArrayHasKey('payload', $payload); + $this->assertStringStartsWith('ey', $payload['payload']); + $this->assertArrayHasKey('signature', $payload); + $this->assertNotEmpty($payload['signature']); + } + public function testRequestPayload() { $container = []; From 0e659d45c1765ad020d13f2aa5bf98eadcbe2a75 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Wed, 14 Aug 2024 16:08:09 +0200 Subject: [PATCH 33/77] fix: allow application to run without a git version set --- src/Cli/Application.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 1224cced..18347d33 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -39,11 +39,12 @@ public function __construct() protected function getDefaultCommands(): array { + $version = explode('@', $this->getVersion())[0]; return array_merge(parent::getDefaultCommands(), [ new RunCommand(), new RevokeCommand(), new StatusCommand(), - new SelfUpdateCommand($this->getName(), explode('@', $this->getVersion())[0], 'acmephp/acmephp'), + new SelfUpdateCommand($this->getName(), $version === '' ? '0.0.0' : $version, 'acmephp/acmephp'), ]); } From 0c7b448c07c735d3725df544e980b54756c93f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 18:24:53 +0200 Subject: [PATCH 34/77] update monolog and psr/log --- CHANGELOG.md | 13 ++++++++++++ composer.json | 4 ++-- src/Cli/Command/AbstractCommand.php | 2 +- src/Cli/Monolog/ConsoleFormatter.php | 30 +++++++++++++++++---------- src/Cli/Monolog/ConsoleHandler.php | 15 +++++++++++--- tests/Cli/AbstractApplicationTest.php | 15 ++++++++++---- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed010da4..890b5d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,21 @@ > [!NOTE] > From now on, a particular attention will be given to provide a nice changelog. +### Features + +* Drop support for monolog ^3 +* Drop support for psr/log ^2 || ^3 + +### BC Break + * Drop support for PHP <8.1 * Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 +* Drop support for monolog < 2 +* Drop support for psr/log < 2 + +### Internal + +* Update PHP-CS-Fixer to 3.62.0 ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements diff --git a/composer.json b/composer.json index b0d8e57e..d14c3566 100644 --- a/composer.json +++ b/composer.json @@ -50,11 +50,11 @@ "league/flysystem": "^3.10", "league/flysystem-memory": "^3.10", "league/flysystem-sftp-v3": "^3.10", - "monolog/monolog": "^1.19|^2.0", + "monolog/monolog": "^2.0 || ^3", "padraic/phar-updater": "^1.0", "psr/container": "^1.0", "psr/http-message": "^1.0", - "psr/log": "^1.0", + "psr/log": "^2 || ^3", "symfony/config": "^5.4.12 || ^6.4", "symfony/console": "^5.4.12 || ^6.4", "symfony/dependency-injection": "^5.4.12 || ^6.4", diff --git a/src/Cli/Command/AbstractCommand.php b/src/Cli/Command/AbstractCommand.php index 408bd164..ce208626 100644 --- a/src/Cli/Command/AbstractCommand.php +++ b/src/Cli/Command/AbstractCommand.php @@ -30,7 +30,7 @@ /** * @author Titouan Galopin */ -abstract class AbstractCommand extends Command implements LoggerInterface +abstract class AbstractCommand extends Command { /** * @var InputInterface diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index 36346f2f..127e527b 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -25,29 +25,37 @@ */ class ConsoleFormatter extends LineFormatter { - public const SIMPLE_FORMAT = "%start_tag%%message% %context% %extra%%end_tag%\n"; + public const SIMPLE_FORMAT = "%extra.start_tag%%message% %context% %extra%%extra.end_tag%\n"; public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false, $ignoreEmptyContextAndExtra = true) { parent::__construct($format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra); } - public function format(array $record): string + /** + * @param LogRecord|array $record + */ + public function format($record): string { if ($record['level'] >= Logger::ERROR) { - $record['start_tag'] = ''; - $record['end_tag'] = ''; + $extra['start_tag'] = ''; + $extra['end_tag'] = ''; } elseif ($record['level'] >= Logger::WARNING) { - $record['start_tag'] = ''; - $record['end_tag'] = ''; + $extra['start_tag'] = ''; + $extra['end_tag'] = ''; } elseif ($record['level'] >= Logger::NOTICE) { - $record['start_tag'] = ''; - $record['end_tag'] = ''; + $extra['start_tag'] = ''; + $extra['end_tag'] = ''; } else { - $record['start_tag'] = ''; - $record['end_tag'] = ''; + $extra['start_tag'] = ''; + $extra['end_tag'] = ''; } - return parent::format($record); + $record['extra'] = [ + ...$record['extra'], + ...$extra, + ]; + + return dump(parent::format($record)); } } diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index f509b638..6c06608d 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -63,12 +63,18 @@ public function __construct(?OutputInterface $output = null, bool $bubble = true } } - public function isHandling(array $record): bool + /** + * @param LogRecord|array $record + */ + public function isHandling($record): bool { return $this->updateLevel() && parent::isHandling($record); } - public function handle(array $record): bool + /** + * @param LogRecord|array $record + */ + public function handle($record): bool { // we have to update the logging level each time because the verbosity of the // console output might have changed in the meantime (it is not immutable) @@ -95,7 +101,10 @@ public function close(): void parent::close(); } - protected function write(array $record): void + /** + * @param LogRecord|array $record + */ + protected function write($record): void { $this->output->write((string) $record['formatted']); } diff --git a/tests/Cli/AbstractApplicationTest.php b/tests/Cli/AbstractApplicationTest.php index be8da5c0..62ebf8ae 100644 --- a/tests/Cli/AbstractApplicationTest.php +++ b/tests/Cli/AbstractApplicationTest.php @@ -43,13 +43,20 @@ public function tearDown(): void public function testFullProcess() { $runTester = new CommandTester($this->application->find('run')); - $runTester->execute([ - 'command' => 'run', - 'config' => $this->getConfigDir().'/'.('eab' === getenv('PEBBLE_MODE') ? 'eab' : 'default').'.yaml', - ]); + $runTester->execute( + [ + 'command' => 'run', + 'config' => $this->getConfigDir().'/'.('eab' === getenv('PEBBLE_MODE') ? 'eab' : 'default').'.yaml', + ], + [ + 'decorated' => true, + ] + ); $output = $runTester->getDisplay(); + $this->assertStringContainsString("\e[32mLoading account key pair... \e[39m", $output); + // Register $this->assertStringContainsString('No account key pair was found, generating one', $output); $this->assertStringContainsString('Account registered successfully', $output); From bef542f37d95deaa30536833872e0ca6ebdf4204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 18:04:29 +0200 Subject: [PATCH 35/77] update guzzlehttp/psr7 to ^2.4.5 --- CHANGELOG.md | 12 ++++++++++++ composer.json | 2 +- src/Cli/Action/PushRancherAction.php | 4 ++-- src/Cli/Command/RunCommand.php | 4 ++-- tests/Core/Http/SecureHttpClientTest.php | 3 +-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed010da4..6232754d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,20 @@ > [!NOTE] > From now on, a particular attention will be given to provide a nice changelog. +### Features + +* Add support for guzzlehttp/psr7 ^2.4 + +### BC Break + * Drop support for PHP <8.1 * Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 +* Drop support for guzzlehttp/psr7 < 2 +* Upgrade from FlySystem v1 to v3 + +### Internal + +* Update PHP-CS-Fixer to 3.62.0 ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements diff --git a/composer.json b/composer.json index b0d8e57e..eebdb334 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "alibabacloud/wafopenapi": "^1.7", "aws/aws-sdk-php": "^3.38", "guzzlehttp/guzzle": "^7.2", - "guzzlehttp/psr7": "^1.0", + "guzzlehttp/psr7": "^2.4.5", "lcobucci/jwt": "^3.3|^4.0", "league/flysystem": "^3.10", "league/flysystem-memory": "^3.10", diff --git a/src/Cli/Action/PushRancherAction.php b/src/Cli/Action/PushRancherAction.php index 015804ea..1dd33c2c 100644 --- a/src/Cli/Action/PushRancherAction.php +++ b/src/Cli/Action/PushRancherAction.php @@ -65,7 +65,7 @@ private function createRancherPayloadFromResponse(CertificateResponse $response) return $certificate->getPEM(); }, $certificate->getIssuerChain()); - return \GuzzleHttp\json_encode([ + return json_encode([ 'name' => $response->getCertificateRequest()->getDistinguishedName()->getCommonName(), 'description' => 'Generated with Acme PHP', 'cert' => $certificate->getPEM(), @@ -123,6 +123,6 @@ private function request($method, $url, $body = null) 'body' => $body ?: '', ]); - return \GuzzleHttp\json_decode(\GuzzleHttp\Psr7\copy_to_string($response->getBody()), true); + return json_decode((string) $response->getBody(), true); } } diff --git a/src/Cli/Command/RunCommand.php b/src/Cli/Command/RunCommand.php index cca39a3c..bd85f273 100644 --- a/src/Cli/Command/RunCommand.php +++ b/src/Cli/Command/RunCommand.php @@ -145,7 +145,7 @@ private function resolveEabKid(): ?ExternalAccount if ('zerossl' === $this->config['provider']) { // If an API key is provided, use it if ($this->config['zerossl_api_key']) { - $eabCredentials = \GuzzleHttp\json_decode( + $eabCredentials = json_decode( (new Client()) ->post('https://api.zerossl.com/acme/eab-credentials/?access_key='.$this->config['zerossl_api_key']) ->getBody() @@ -160,7 +160,7 @@ private function resolveEabKid(): ?ExternalAccount } // Otherwise register on the fly - $eabCredentials = \GuzzleHttp\json_decode( + $eabCredentials = json_decode( (new Client()) ->post('https://api.zerossl.com/acme/eab-credentials-email', [ 'form_params' => ['email' => $this->config['contact_email']], diff --git a/tests/Core/Http/SecureHttpClientTest.php b/tests/Core/Http/SecureHttpClientTest.php index 649bc9da..fb20b080 100644 --- a/tests/Core/Http/SecureHttpClientTest.php +++ b/tests/Core/Http/SecureHttpClientTest.php @@ -177,8 +177,7 @@ public function testRequestPayload() $this->assertEquals('POST', $request->getMethod()); $this->assertEquals('/acme/new-reg', ($request->getUri() instanceof Uri) ? $request->getUri()->getPath() : $request->getUri()); - $body = \GuzzleHttp\Psr7\copy_to_string($request->getBody()); - $payload = @json_decode($body, true); + $payload = @json_decode((string) $request->getBody(), true); $this->assertIsArray($payload); $this->assertArrayHasKey('protected', $payload); From cf7113dec734c21d0a9af5cbd07bb54ad97e96e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 14 Aug 2024 18:29:22 +0200 Subject: [PATCH 36/77] Restore missing tests with PEBBLE_MODE=EAB --- .github/workflows/test-build.yaml | 12 +++++++++++- tests/Cli/Fixtures/config/sfpt_nginxproxy/eab.yaml | 2 +- tests/Cli/Fixtures/config/simple/eab.yaml | 2 +- tests/Core/AcmeClientTest.php | 4 ++-- tests/Fixtures/pebble-config-eab.json | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 38b8644b..f748d12f 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -24,7 +24,7 @@ jobs: run: php php-cs-fixer.phar fix --dry-run --diff ci: - name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} + name: Test PHP ${{ matrix.php-version }} ${{ matrix.pebble_mode }} ${{ matrix.name }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -32,10 +32,20 @@ jobs: php-version: ["8.2", "8.3"] composer-flags: [""] name: [""] + pebble_mode: [""] include: - php-version: 8.1 composer-flags: "--prefer-lowest" name: "(prefer lowest dependencies)" + - php-version: 8.1 + composer-flags: "--prefer-lowest" + name: "(prefer lowest dependencies - EAB)" + pebble_mode: eab + - php-version: 8.3 + name: "(EAB)" + pebble_mode: eab + env: + PEBBLE_MODE: "${{ matrix.pebble_mode }}" steps: - uses: shivammathur/setup-php@v2 diff --git a/tests/Cli/Fixtures/config/sfpt_nginxproxy/eab.yaml b/tests/Cli/Fixtures/config/sfpt_nginxproxy/eab.yaml index c3f20952..cfc6dfca 100644 --- a/tests/Cli/Fixtures/config/sfpt_nginxproxy/eab.yaml +++ b/tests/Cli/Fixtures/config/sfpt_nginxproxy/eab.yaml @@ -2,7 +2,7 @@ contact_email: foo@example.com key_type: RSA provider: localhost eab_kid: kid1 -eab_hmac_key: dGVzdGluZw +eab_hmac_key: dGVzdGluZ3Rlc3Rpbmd0ZXN0aW5ndGVzdGluZ3Rlc3Rpbmd0ZXN0aW5n defaults: distinguished_name: diff --git a/tests/Cli/Fixtures/config/simple/eab.yaml b/tests/Cli/Fixtures/config/simple/eab.yaml index 12f78b1e..6d8ee8ce 100644 --- a/tests/Cli/Fixtures/config/simple/eab.yaml +++ b/tests/Cli/Fixtures/config/simple/eab.yaml @@ -2,7 +2,7 @@ contact_email: foo@example.com key_type: RSA provider: localhost eab_kid: kid1 -eab_hmac_key: dGVzdGluZw +eab_hmac_key: dGVzdGluZ3Rlc3Rpbmd0ZXN0aW5ndGVzdGluZ3Rlc3Rpbmd0ZXN0aW5n defaults: distinguished_name: diff --git a/tests/Core/AcmeClientTest.php b/tests/Core/AcmeClientTest.php index 0838684c..302ab02b 100644 --- a/tests/Core/AcmeClientTest.php +++ b/tests/Core/AcmeClientTest.php @@ -62,7 +62,7 @@ public function testFullProcess(KeyOption $keyOption, bool $useAlternateCertific * Register account */ if ('eab' === getenv('PEBBLE_MODE')) { - $data = $client->registerAccount('titouan.galopin@acmephp.com', new ExternalAccount('kid1', 'dGVzdGluZw')); + $data = $client->registerAccount('titouan.galopin@acmephp.com', new ExternalAccount('kid1', 'dGVzdGluZ3Rlc3Rpbmd0ZXN0aW5ndGVzdGluZ3Rlc3Rpbmd0ZXN0aW5n')); } else { $data = $client->registerAccount('titouan.galopin@acmephp.com'); } @@ -152,7 +152,7 @@ public function testRequestAuthorizationAllowsCapitalisation(KeyOption $keyOptio * Register account */ if ('eab' === getenv('PEBBLE_MODE')) { - $client->registerAccount('titouan.galopin@acmephp.com', new ExternalAccount('kid1', 'dGVzdGluZw')); + $client->registerAccount('titouan.galopin@acmephp.com', new ExternalAccount('kid1', 'dGVzdGluZ3Rlc3Rpbmd0ZXN0aW5ndGVzdGluZ3Rlc3Rpbmd0ZXN0aW5n')); } else { $client->registerAccount('titouan.galopin@acmephp.com'); } diff --git a/tests/Fixtures/pebble-config-eab.json b/tests/Fixtures/pebble-config-eab.json index 6c01253f..95a4e69b 100644 --- a/tests/Fixtures/pebble-config-eab.json +++ b/tests/Fixtures/pebble-config-eab.json @@ -9,7 +9,7 @@ "ocspResponderURL": "", "externalAccountBindingRequired": true, "externalAccountMACKeys": { - "kid1": "dGVzdGluZw" + "kid1": "dGVzdGluZ3Rlc3Rpbmd0ZXN0aW5ndGVzdGluZ3Rlc3Rpbmd0ZXN0aW5n" } } } From a043367f391ef3db7ecf8a9d93666cd301fdc45f Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 1 Jan 2022 22:54:21 +0100 Subject: [PATCH 37/77] Replace deprected webmozart/path-util with symfony/filesystem --- composer.json | 3 +-- src/Cli/Application.php | 2 +- src/Cli/Command/RunCommand.php | 2 +- tests/Cli/Mock/TestApplication.php | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index b0d8e57e..15fc2214 100644 --- a/composer.json +++ b/composer.json @@ -61,8 +61,7 @@ "symfony/filesystem": "^5.4.12 || ^6.4", "symfony/serializer": "^5.4.12 || ^6.4", "symfony/yaml": "^5.4.12 || ^6.4", - "webmozart/assert": "^1.0", - "webmozart/path-util": "^2.3" + "webmozart/assert": "^1.0" }, "require-dev": { "symfony/finder": "^5.4.12 || ^6.4", diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 2dc1171f..e34fb54f 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -18,7 +18,7 @@ use AcmePhp\Cli\Command\StatusCommand; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Helper\HelperSet; -use Webmozart\PathUtil\Path; +use Symfony\Component\Filesystem\Path; /** * @author Titouan Galopin diff --git a/src/Cli/Command/RunCommand.php b/src/Cli/Command/RunCommand.php index cca39a3c..25716128 100644 --- a/src/Cli/Command/RunCommand.php +++ b/src/Cli/Command/RunCommand.php @@ -38,8 +38,8 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\Filesystem\Exception\IOException; +use Symfony\Component\Filesystem\Path; use Symfony\Component\Yaml\Yaml; -use Webmozart\PathUtil\Path; /** * @author Jérémy Derussé diff --git a/tests/Cli/Mock/TestApplication.php b/tests/Cli/Mock/TestApplication.php index dbc4f4c3..4ab3234b 100644 --- a/tests/Cli/Mock/TestApplication.php +++ b/tests/Cli/Mock/TestApplication.php @@ -11,7 +11,7 @@ namespace Tests\AcmePhp\Cli\Mock; -use Webmozart\PathUtil\Path; +use Symfony\Component\Filesystem\Path; class TestApplication extends \AcmePhp\Cli\Application { From f75cb60c327c568aedaf5fd77db2f6190913b39c Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 10:48:55 +0200 Subject: [PATCH 38/77] chore(cs): manually fix cs issues --- src/Cli/Application.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 18347d33..b7fd7bba 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -40,11 +40,12 @@ public function __construct() protected function getDefaultCommands(): array { $version = explode('@', $this->getVersion())[0]; + return array_merge(parent::getDefaultCommands(), [ new RunCommand(), new RevokeCommand(), new StatusCommand(), - new SelfUpdateCommand($this->getName(), $version === '' ? '0.0.0' : $version, 'acmephp/acmephp'), + new SelfUpdateCommand($this->getName(), '' === $version ? '0.0.0' : $version, 'acmephp/acmephp'), ]); } From 8ac1a5b143c3b3d2dd3eed5398412b4d27933ebc Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 11:22:39 +0200 Subject: [PATCH 39/77] chore: drop old php BREAKING CHANGE: requires PHP8.3 or greater --- composer.json | 2 +- src/Core/composer.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b0d8e57e..c176a170 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.3", "ext-filter": "*", "ext-hash": "*", "ext-json": "*", diff --git a/src/Core/composer.json b/src/Core/composer.json index 4955887d..1e72f35d 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -27,7 +27,7 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.3", "ext-hash": "*", "ext-json": "*", "ext-openssl": "*", @@ -35,6 +35,7 @@ "guzzlehttp/guzzle": "^6.0|^7.0", "guzzlehttp/psr7": "^1.7|^2.1", "lcobucci/jwt": "^3.3|^4.0", + "psr/http-client": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0|^2.0|^3.0", "webmozart/assert": "^1.0" From 701f901bdea558b9f99601fb8b7034ff6c17fe6b Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 11:25:38 +0200 Subject: [PATCH 40/77] fix: remove rancher 1 push action BREAKING CHANGE: Rancher is no longer supported --- src/Cli/Action/PushRancherAction.php | 128 --------------------------- 1 file changed, 128 deletions(-) delete mode 100644 src/Cli/Action/PushRancherAction.php diff --git a/src/Cli/Action/PushRancherAction.php b/src/Cli/Action/PushRancherAction.php deleted file mode 100644 index 015804ea..00000000 --- a/src/Cli/Action/PushRancherAction.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace AcmePhp\Cli\Action; - -use AcmePhp\Ssl\Certificate; -use AcmePhp\Ssl\CertificateResponse; -use GuzzleHttp\Client; -use GuzzleHttp\Psr7\Uri; - -/** - * Action to upload SSL certificates to Rancher using its API. - * - * @see http://docs.rancher.com/rancher/v1.2/en/api/api-resources/certificate/ - * - * @author Titouan Galopin - */ -class PushRancherAction implements ActionInterface -{ - /** - * @var Client - */ - private $httpClient; - - public function __construct(Client $httpClient) - { - $this->httpClient = $httpClient; - } - - public function handle(array $config, CertificateResponse $response) - { - $payload = $this->createRancherPayloadFromResponse($response); - - $commonName = $response->getCertificateRequest()->getDistinguishedName()->getCommonName(); - $currentCertificates = $this->getRancherCertificates($config); - - $updated = false; - - foreach ($currentCertificates as $certificate) { - if ($certificate['name'] === $commonName) { - $updated = true; - $this->updateRancherCertificate($config, $certificate['id'], $payload); - } - } - - if (!$updated) { - $this->createRancherCertificate($config, $payload); - } - } - - private function createRancherPayloadFromResponse(CertificateResponse $response) - { - $certificate = $response->getCertificate(); - $privateKey = $response->getCertificateRequest()->getKeyPair()->getPrivateKey(); - - $issuerChain = array_map(function (Certificate $certificate) { - return $certificate->getPEM(); - }, $certificate->getIssuerChain()); - - return \GuzzleHttp\json_encode([ - 'name' => $response->getCertificateRequest()->getDistinguishedName()->getCommonName(), - 'description' => 'Generated with Acme PHP', - 'cert' => $certificate->getPEM(), - 'certChain' => implode("\n", $issuerChain), - 'key' => $privateKey->getPEM(), - ]); - } - - private function getRancherCertificates($config) - { - $nextPage = $this->createUrl($config, '/v1/certificates'); - $certificates = []; - - while ($nextPage) { - $page = $this->request('GET', $nextPage); - $certificates = array_merge($certificates, $page['data']); - - $nextPage = null; - if (isset($page['pagination'], $page['pagination']['next']) && \is_string($page['pagination']['next'])) { - $nextPage = $page['pagination']['next']; - } - } - - return $certificates; - } - - private function updateRancherCertificate($config, $previousCertificateId, $newPayload) - { - $this->request('PUT', $this->createUrl($config, '/v1/certificates/'.$previousCertificateId), $newPayload); - } - - private function createRancherCertificate($config, $payload) - { - $this->request('POST', $this->createUrl($config, '/v1/certificates'), $payload); - } - - private function createUrl($config, $endpoint) - { - $url = (new Uri()) - ->withScheme($config['ssl'] ? 'https' : 'http') - ->withUserInfo($config['access_key'], $config['secret_key']) - ->withHost($config['host']) - ->withPort($config['port']) - ->withPath($endpoint); - - return (string) $url; - } - - private function request($method, $url, $body = null) - { - $response = $this->httpClient->request($method, $url, [ - 'headers' => [ - 'Content-Type' => 'application/json', - ], - 'body' => $body ?: '', - ]); - - return \GuzzleHttp\json_decode(\GuzzleHttp\Psr7\copy_to_string($response->getBody()), true); - } -} From f7505d1217c8b96737e8dd96f41395f7d5bf674c Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 11:58:59 +0200 Subject: [PATCH 41/77] chore: remove old php versions from ci --- .github/workflows/test-build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 38b8644b..ca820259 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none - uses: actions/checkout@master @@ -29,11 +29,11 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["8.2", "8.3"] + php-version: ["8.3"] composer-flags: [""] name: [""] include: - - php-version: 8.1 + - php-version: 8.3 composer-flags: "--prefer-lowest" name: "(prefer lowest dependencies)" From 90870e63571f9a6b047e77af48c0852c7ff850e9 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 12:23:20 +0200 Subject: [PATCH 42/77] chore: clean changelog --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64e0b869..841899ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,10 @@ * Drop support for PHP <8.1 * Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 -* Upgrade from FlySystem v1 to v3 ### Internal * Update PHP-CS-Fixer to 3.62.0 -* Analyse code with PHPStan ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements From 1deb706bb03188d5ff0d7adddfacca3c61406995 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 12:25:43 +0200 Subject: [PATCH 43/77] chore: clean changelog correctly --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 841899ce..d6ba6976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ ### Internal -* Update PHP-CS-Fixer to 3.62.0 +* Analyse code with PHPStan ## 07/06/2022 22:41 2.1.0 Add compatibility for PHP 8.0/8.1, Symfony 6 and other improvements From b77609ac00b178313216ed87f45366511acdb63e Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 13:19:55 +0200 Subject: [PATCH 44/77] chore: fix phpstan issues --- phpstan-baseline.neon | 5 ----- phpstan.neon | 2 ++ src/Cli/Command/RunCommand.php | 8 +++++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1b309a64..1e98fab9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -155,11 +155,6 @@ parameters: count: 1 path: src/Cli/Command/RunCommand.php - - - message: "#^Parameter \\#2 \\$basePath of static method Webmozart\\\\PathUtil\\\\Path\\:\\:makeAbsolute\\(\\) expects string, string\\|false given\\.$#" - count: 1 - path: src/Cli/Command/RunCommand.php - - message: "#^Property AcmePhp\\\\Cli\\\\Command\\\\RunCommand\\:\\:\\$config has no type specified\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index 03a0bac5..17850572 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,6 +3,8 @@ includes: parameters: level: 7 + excludePaths: + - src/Core/vendor paths: - src diff --git a/src/Cli/Command/RunCommand.php b/src/Cli/Command/RunCommand.php index 25716128..daa13489 100644 --- a/src/Cli/Command/RunCommand.php +++ b/src/Cli/Command/RunCommand.php @@ -71,7 +71,13 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - $this->config = $this->getConfig(Path::makeAbsolute($input->getArgument('config'), getcwd())); + + $cwd = getcwd(); + if ($cwd === false) { + throw new \RuntimeException('Failed to get current working directory'); + } + + $this->config = $this->getConfig(Path::makeAbsolute($input->getArgument('config'), $cwd)); $keyOption = $this->createKeyOption($this->config['key_type']); $this->register($this->config['contact_email'], $keyOption); From e38b4dd0f3073bac7c8122cb6ba32d2c0967e23a Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 13:21:19 +0200 Subject: [PATCH 45/77] chore(cs): fix cs --- src/Cli/Command/RunCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Cli/Command/RunCommand.php b/src/Cli/Command/RunCommand.php index daa13489..a26d2a28 100644 --- a/src/Cli/Command/RunCommand.php +++ b/src/Cli/Command/RunCommand.php @@ -71,9 +71,8 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - $cwd = getcwd(); - if ($cwd === false) { + if (false === $cwd) { throw new \RuntimeException('Failed to get current working directory'); } From ebf5df0483bb4e82876ea8e7b7d65a3751f4baf9 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 13:53:35 +0200 Subject: [PATCH 46/77] chore: dont use (string) cast if it can be avoided --- tests/Core/Http/SecureHttpClientTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Core/Http/SecureHttpClientTest.php b/tests/Core/Http/SecureHttpClientTest.php index fb20b080..4bffdf64 100644 --- a/tests/Core/Http/SecureHttpClientTest.php +++ b/tests/Core/Http/SecureHttpClientTest.php @@ -177,7 +177,7 @@ public function testRequestPayload() $this->assertEquals('POST', $request->getMethod()); $this->assertEquals('/acme/new-reg', ($request->getUri() instanceof Uri) ? $request->getUri()->getPath() : $request->getUri()); - $payload = @json_decode((string) $request->getBody(), true); + $payload = json_decode($request->getBody()->getContents(), true, JSON_THROW_ON_ERROR); $this->assertIsArray($payload); $this->assertArrayHasKey('protected', $payload); From 2ba32c98bb08f79c3b10df06d0d7e0cfb15c5fd5 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 13:57:10 +0200 Subject: [PATCH 47/77] chore(ci): use php 8.3 in test --- .github/workflows/test-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 71891768..5a5a6e4d 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -54,7 +54,7 @@ jobs: - php-version: 8.3 composer-flags: "--prefer-lowest" name: "(prefer lowest dependencies)" - - php-version: 8.1 + - php-version: 8.3 composer-flags: "--prefer-lowest" name: "(prefer lowest dependencies - EAB)" pebble_mode: eab From 632f74772cebaed65fd2e89a66085ae0bb236786 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:05:24 +0200 Subject: [PATCH 48/77] fix: update to lcobucci/jwt ^5.3 --- composer.json | 2 +- src/Core/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a169d46e..780f3824 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "consolidation/self-update": "^2.2", "guzzlehttp/guzzle": "^7.2", "guzzlehttp/psr7": "^1.0", - "lcobucci/jwt": "^4.1 || ^5.3", + "lcobucci/jwt": "^5.3", "league/flysystem": "^3.10", "league/flysystem-memory": "^3.10", "league/flysystem-sftp-v3": "^3.10", diff --git a/src/Core/composer.json b/src/Core/composer.json index 1e72f35d..615dc6a2 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -34,7 +34,7 @@ "acmephp/ssl": "^2.0", "guzzlehttp/guzzle": "^6.0|^7.0", "guzzlehttp/psr7": "^1.7|^2.1", - "lcobucci/jwt": "^3.3|^4.0", + "lcobucci/jwt": "^5.3", "psr/http-client": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0|^2.0|^3.0", From 52564bb4d4ab8827dca0373bcc10b63afb94afe1 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:13:00 +0200 Subject: [PATCH 49/77] chore(sa): regenerate baseline --- phpstan-baseline.neon | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1e98fab9..9088f242 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -405,11 +405,6 @@ parameters: count: 1 path: src/Core/Filesystem/Adapter/FlysystemLocalFactory.php - - - message: "#^Call to an undefined method Lcobucci\\\\JWT\\\\Signer\\\\Hmac\\\\Sha256\\:\\:getAlgorithmId\\(\\)\\.$#" - count: 1 - path: src/Core/Http/SecureHttpClient.php - - message: "#^Left side of && is always true\\.$#" count: 1 From 1e293154665945aa5c857fbd36196982c4cb66a3 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:38:03 +0200 Subject: [PATCH 50/77] fix: also drop monolog 2 for better typing --- CHANGELOG.md | 4 +- composer.json | 2 +- phpstan-baseline.neon | 90 ---------------------------- src/Cli/Command/AbstractCommand.php | 18 +++--- src/Cli/Monolog/ConsoleFormatter.php | 40 ++++++------- src/Cli/Monolog/ConsoleHandler.php | 50 ++++++---------- 6 files changed, 50 insertions(+), 154 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecb5a39f..d7251c4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,8 +17,8 @@ * Drop support for lcobucci/jwt < 5.3 * Drop support for guzzlehttp/psr7 < 2 * Upgrade from FlySystem v1 to v3 -* Drop support for monolog ^3 -* Drop support for psr/log ^2 || ^3 +* Drop support for monolog ^1 +* Drop support for psr/log ^1 ### Internal diff --git a/composer.json b/composer.json index 740d6071..f27d0a98 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "league/flysystem": "^3.10", "league/flysystem-memory": "^3.10", "league/flysystem-sftp-v3": "^3.10", - "monolog/monolog": "^2.0 || ^3", + "monolog/monolog": "^3", "psr/container": "^1.0", "psr/http-message": "^1.0", "psr/log": "^2 || ^3", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9088f242..53c9bea1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,31 +15,6 @@ parameters: count: 1 path: src/Cli/Command/AbstractCommand.php - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:alert\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:critical\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:debug\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:emergency\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:error\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:getCliLogger\\(\\) should return Psr\\\\Log\\\\LoggerInterface but returns object\\.$#" count: 1 @@ -50,71 +25,6 @@ parameters: count: 1 path: src/Cli/Command/AbstractCommand.php - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:info\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:log\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:notice\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\AbstractCommand\\:\\:warning\\(\\) with return type void returns null but should not return anything\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:alert\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:critical\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:debug\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:emergency\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:error\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:info\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:log\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:notice\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - - - message: "#^Result of method Psr\\\\Log\\\\LoggerInterface\\:\\:warning\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: src/Cli/Command/AbstractCommand.php - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\RevokeCommand\\:\\:execute\\(\\) should return int but empty return statement found\\.$#" count: 3 diff --git a/src/Cli/Command/AbstractCommand.php b/src/Cli/Command/AbstractCommand.php index ce208626..356561d4 100644 --- a/src/Cli/Command/AbstractCommand.php +++ b/src/Cli/Command/AbstractCommand.php @@ -133,46 +133,46 @@ private function initializeContainer() public function emergency($message, array $context = []) { - return $this->getCliLogger()->emergency($message, $context); + $this->getCliLogger()->emergency($message, $context); } public function alert($message, array $context = []) { - return $this->getCliLogger()->alert($message, $context); + $this->getCliLogger()->alert($message, $context); } public function critical($message, array $context = []) { - return $this->getCliLogger()->critical($message, $context); + $this->getCliLogger()->critical($message, $context); } public function error($message, array $context = []) { - return $this->getCliLogger()->error($message, $context); + $this->getCliLogger()->error($message, $context); } public function warning($message, array $context = []) { - return $this->getCliLogger()->warning($message, $context); + $this->getCliLogger()->warning($message, $context); } public function notice($message, array $context = []) { - return $this->getCliLogger()->notice($message, $context); + $this->getCliLogger()->notice($message, $context); } public function info($message, array $context = []) { - return $this->getCliLogger()->info($message, $context); + $this->getCliLogger()->info($message, $context); } public function debug($message, array $context = []) { - return $this->getCliLogger()->debug($message, $context); + $this->getCliLogger()->debug($message, $context); } public function log($level, $message, array $context = []) { - return $this->getCliLogger()->log($level, $message, $context); + $this->getCliLogger()->log($level, $message, $context); } } diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index 127e527b..8f8e63f6 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -12,7 +12,9 @@ namespace AcmePhp\Cli\Monolog; use Monolog\Formatter\LineFormatter; +use Monolog\Level; use Monolog\Logger; +use Monolog\LogRecord; /** * Formats incoming records for console output by coloring them depending on log level. @@ -25,37 +27,35 @@ */ class ConsoleFormatter extends LineFormatter { - public const SIMPLE_FORMAT = "%extra.start_tag%%message% %context% %extra%%extra.end_tag%\n"; + public const string SIMPLE_FORMAT = "%extra.start_tag%%message% %context% %extra%%extra.end_tag%\n"; public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false, $ignoreEmptyContextAndExtra = true) { parent::__construct($format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra); } - /** - * @param LogRecord|array $record - */ - public function format($record): string + public function format(LogRecord $record): string { - if ($record['level'] >= Logger::ERROR) { - $extra['start_tag'] = ''; - $extra['end_tag'] = ''; - } elseif ($record['level'] >= Logger::WARNING) { - $extra['start_tag'] = ''; - $extra['end_tag'] = ''; - } elseif ($record['level'] >= Logger::NOTICE) { - $extra['start_tag'] = ''; - $extra['end_tag'] = ''; + if ($record->level->isHigherThan(Level::Error)) { + $start = ''; + $end = ''; + } elseif ($record->level->isHigherThan(Level::Warning)) { + $start = ''; + $end = ''; + } elseif ($record->level->isHigherThan(Level::Notice)) { + $start = ''; + $end = ''; } else { - $extra['start_tag'] = ''; - $extra['end_tag'] = ''; + $start = ''; + $end = ''; } - $record['extra'] = [ - ...$record['extra'], - ...$extra, + $record->extra = [ + ...$record->extra, + 'start_tag' => $start, + 'end_tag' => $end, ]; - return dump(parent::format($record)); + return parent::format($record); } } diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index 6c06608d..f15a2a3e 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -13,7 +13,9 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Handler\AbstractProcessingHandler; +use Monolog\Level; use Monolog\Logger; +use Monolog\LogRecord; use Symfony\Component\Console\Output\OutputInterface; /** @@ -28,19 +30,14 @@ class ConsoleHandler extends AbstractProcessingHandler { /** - * @var OutputInterface|null + * @var array */ - private $output; - - /** - * @var array - */ - private $verbosityLevelMap = [ - OutputInterface::VERBOSITY_QUIET => Logger::ERROR, - OutputInterface::VERBOSITY_NORMAL => Logger::INFO, - OutputInterface::VERBOSITY_VERBOSE => Logger::INFO, - OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO, - OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG, + private array $verbosityLevelMap = [ + OutputInterface::VERBOSITY_QUIET => Level::Error, + OutputInterface::VERBOSITY_NORMAL => Level::Info, + OutputInterface::VERBOSITY_VERBOSE => Level::Info, + OutputInterface::VERBOSITY_VERY_VERBOSE => Level::Info, + OutputInterface::VERBOSITY_DEBUG => Level::Info, ]; /** @@ -52,29 +49,21 @@ class ConsoleHandler extends AbstractProcessingHandler * @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging * level (leave empty to use the default mapping) */ - public function __construct(?OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = []) + public function __construct(private OutputInterface|null $output = null, bool $bubble = true, array $verbosityLevelMap = []) { - parent::__construct(Logger::DEBUG, $bubble); + parent::__construct(Level::Debug, $bubble); - $this->output = $output; - - if ($verbosityLevelMap) { + if ($verbosityLevelMap !== []) { $this->verbosityLevelMap = $verbosityLevelMap; } } - /** - * @param LogRecord|array $record - */ - public function isHandling($record): bool + public function isHandling(LogRecord $record): bool { return $this->updateLevel() && parent::isHandling($record); } - /** - * @param LogRecord|array $record - */ - public function handle($record): bool + public function handle(LogRecord $record): bool { // we have to update the logging level each time because the verbosity of the // console output might have changed in the meantime (it is not immutable) @@ -86,7 +75,7 @@ public function handle($record): bool * * @param OutputInterface $output The console output to use */ - public function setOutput(OutputInterface $output) + public function setOutput(OutputInterface $output): void { $this->output = $output; } @@ -101,10 +90,7 @@ public function close(): void parent::close(); } - /** - * @param LogRecord|array $record - */ - protected function write($record): void + protected function write(LogRecord|array $record): void { $this->output->write((string) $record['formatted']); } @@ -122,7 +108,7 @@ protected function getDefaultFormatter(): FormatterInterface * * @return bool Whether the handler is enabled and verbosity is not set to quiet */ - private function updateLevel() + private function updateLevel(): bool { if (null === $this->output) { return false; @@ -132,7 +118,7 @@ private function updateLevel() if (isset($this->verbosityLevelMap[$verbosity])) { $this->setLevel($this->verbosityLevelMap[$verbosity]); } else { - $this->setLevel(Logger::DEBUG); + $this->setLevel(Level::Debug); } return true; From 86a5615662b4358c199adfdf90a258d965c65515 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:49:34 +0200 Subject: [PATCH 51/77] fix: log level coloring using LogRecord checks --- src/Cli/Monolog/ConsoleFormatter.php | 6 +++--- src/Cli/Monolog/ConsoleHandler.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index 8f8e63f6..a740219e 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -36,13 +36,13 @@ public function __construct($format = null, $dateFormat = null, $allowInlineLine public function format(LogRecord $record): string { - if ($record->level->isHigherThan(Level::Error)) { + if (Level::Error->includes($record->level)) { $start = ''; $end = ''; - } elseif ($record->level->isHigherThan(Level::Warning)) { + } elseif (Level::Warning->includes($record->level)) { $start = ''; $end = ''; - } elseif ($record->level->isHigherThan(Level::Notice)) { + } elseif (Level::Notice->includes($record->level)) { $start = ''; $end = ''; } else { diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index f15a2a3e..716426d7 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -30,7 +30,7 @@ class ConsoleHandler extends AbstractProcessingHandler { /** - * @var array + * @var array */ private array $verbosityLevelMap = [ OutputInterface::VERBOSITY_QUIET => Level::Error, From 507a60ee290d2f25c787a6fc2570891ad66ad66d Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:51:25 +0200 Subject: [PATCH 52/77] chore(cs): manually fix cs --- src/Cli/Monolog/ConsoleFormatter.php | 2 +- src/Cli/Monolog/ConsoleHandler.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index a740219e..0c713585 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -37,7 +37,7 @@ public function __construct($format = null, $dateFormat = null, $allowInlineLine public function format(LogRecord $record): string { if (Level::Error->includes($record->level)) { - $start = ''; + $start = ''; $end = ''; } elseif (Level::Warning->includes($record->level)) { $start = ''; diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index 716426d7..59b1a78a 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -49,11 +49,11 @@ class ConsoleHandler extends AbstractProcessingHandler * @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging * level (leave empty to use the default mapping) */ - public function __construct(private OutputInterface|null $output = null, bool $bubble = true, array $verbosityLevelMap = []) + public function __construct(private ?OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = []) { parent::__construct(Level::Debug, $bubble); - if ($verbosityLevelMap !== []) { + if ([] !== $verbosityLevelMap) { $this->verbosityLevelMap = $verbosityLevelMap; } } From d5bda73f321a47033b70356796b58b7982356657 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:51:50 +0200 Subject: [PATCH 53/77] chore(cs): remove unused import --- src/Cli/Monolog/ConsoleFormatter.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Cli/Monolog/ConsoleFormatter.php b/src/Cli/Monolog/ConsoleFormatter.php index 0c713585..2605bcde 100644 --- a/src/Cli/Monolog/ConsoleFormatter.php +++ b/src/Cli/Monolog/ConsoleFormatter.php @@ -13,7 +13,6 @@ use Monolog\Formatter\LineFormatter; use Monolog\Level; -use Monolog\Logger; use Monolog\LogRecord; /** From cc72046ab5ca24de561f3ddd4f6bbeaef4e8e310 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 14:53:05 +0200 Subject: [PATCH 54/77] chore(cs): remove unused import --- src/Cli/Monolog/ConsoleHandler.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index 59b1a78a..a6cec9e7 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -14,7 +14,6 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Level; -use Monolog\Logger; use Monolog\LogRecord; use Symfony\Component\Console\Output\OutputInterface; From 32c2e96298bac9e48d5dd847b42fb88cf7f2d40a Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:32:02 +0200 Subject: [PATCH 55/77] feat: build docker container on every push to master and during tests --- .github/workflows/build-docker-master.yaml | 37 +++++++++ .github/workflows/test-build.yaml | 29 +++++++ Dockerfile | 93 ++++++---------------- 3 files changed, 90 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/build-docker-master.yaml diff --git a/.github/workflows/build-docker-master.yaml b/.github/workflows/build-docker-master.yaml new file mode 100644 index 00000000..0ad0ce41 --- /dev/null +++ b/.github/workflows/build-docker-master.yaml @@ -0,0 +1,37 @@ +name: Continuous integration (release) +on: + push: + branches: + - master +jobs: + build_container: + name: Build container + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: box + - uses: ramsey/composer-install@v3 + - name: Build PHAR + run: box compile + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.3.0 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v6.0.0 + with: + context: build/ + file: Dockerfile + push: true + tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" +permissions: + packages: write + contents: read diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 5a5a6e4d..fd2b2220 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -23,6 +23,35 @@ jobs: - name: Check coding style run: php php-cs-fixer.phar fix --dry-run --diff + test_docker_build: + name: Build container + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: box + - uses: ramsey/composer-install@v3 + - name: Build PHAR + run: box compile + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.3.0 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v6.0.0 + with: + context: build/ + file: Dockerfile + push: false + tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" + phpstan: name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index b67283f0..a666b269 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,76 +1,31 @@ -FROM alpine:3.8 AS builder - -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - -WORKDIR /srv - -# Composer dependencies -RUN apk add --no-cache \ - php7 \ - php7-phar \ - php7-json \ - php7-iconv \ - php7-mbstring \ - php7-curl \ - php7-ctype \ - php7-opcache \ - php7-sockets \ - php7-openssl - -RUN composer global require "hirak/prestissimo" "jderusse/composer-warmup" - -RUN echo "opcache.enable_cli=1" > /etc/php7/conf.d/opcache.ini \ - && echo "opcache.file_cache='/tmp/opcache'" >> /etc/php7/conf.d/opcache.ini \ - && echo "opcache.file_update_protection=0" >> /etc/php7/conf.d/opcache.ini \ - && mkdir /tmp/opcache - -COPY composer.json /srv/ - -# App dependencies +FROM alpine:edge +ADD acmephp.phar /srv/bin/acme RUN apk add --no-cache \ - php7-simplexml \ - php7-dom \ - php7-tokenizer - -RUN composer install --no-dev --no-scripts --no-suggest --optimize-autoloader \ - && composer require "daverandom/libdns:^2.0.1" --no-scripts --no-suggest --optimize-autoloader - -COPY ./src /srv/src -COPY ./res /srv/res -COPY ./bin /srv/bin - -RUN composer warmup-opcode -- /srv - -# ============================= - -FROM alpine:3.8 + php83 \ + php83-opcache \ + php83-apcu \ + php83-openssl \ + php83-dom \ + php83-mbstring \ + php83-json \ + php83-ctype \ + php83-posix \ + php83-simplexml \ + php83-xmlwriter \ + php83-xml \ + php83-phar \ + php83-curl \ + php83-fileinfo \ + php83-sodium \ + ca-certificates WORKDIR /srv - -# PHP -RUN apk add --no-cache \ - php7 \ - php7-opcache \ - php7-apcu \ - php7-openssl \ - php7-dom \ - php7-mbstring \ - php7-json \ - php7-ctype \ - php7-posix \ - php7-simplexml \ - php7-xmlwriter \ - php7-xml \ - ca-certificates - -RUN echo "date.timezone = UTC" > /etc/php7/conf.d/symfony.ini \ - && echo "opcache.enable_cli=1" > /etc/php7/conf.d/opcache.ini \ - && echo "opcache.file_cache='/tmp/opcache'" >> /etc/php7/conf.d/opcache.ini \ - && echo "opcache.file_update_protection=0" >> /etc/php7/conf.d/opcache.ini \ +RUN chmod +x /srv/bin/acme +RUN echo "date.timezone = UTC" > /etc/php83/conf.d/symfony.ini \ + && echo "opcache.enable_cli=1" > /etc/php83/conf.d/opcache.ini \ + && echo "opcache.file_cache='/tmp/opcache'" >> /etc/php83/conf.d/opcache.ini \ + && echo "opcache.file_update_protection=0" >> /etc/php83/conf.d/opcache.ini \ && mkdir /tmp/opcache ENTRYPOINT ["/srv/bin/acme"] CMD ["list"] - -COPY --from=builder /tmp/opcache /tmp/opcache -COPY --from=builder /srv /srv From 3547c1fb672dfddf488be35b4f29a06fa4b89a66 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:41:57 +0200 Subject: [PATCH 56/77] fix: manually tag during ci so we can build the phar --- .github/workflows/test-build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index fd2b2220..4234f8ff 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -28,6 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - run: git tag ci - name: Setup PHP uses: shivammathur/setup-php@v2 with: From 18b5cf5de4c73ed1568a15d234f63a70fe6a2a8c Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:48:22 +0200 Subject: [PATCH 57/77] chore: test the docker container after building it --- .github/workflows/build-docker-master.yaml | 2 ++ .github/workflows/test-build.yaml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-master.yaml b/.github/workflows/build-docker-master.yaml index 0ad0ce41..32874ce0 100644 --- a/.github/workflows/build-docker-master.yaml +++ b/.github/workflows/build-docker-master.yaml @@ -32,6 +32,8 @@ jobs: file: Dockerfile push: true tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" + - name: Confirm that we can run ACME php via docker + run: docker run --rm -it ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} permissions: packages: write contents: read diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 4234f8ff..49532e7d 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -52,7 +52,8 @@ jobs: file: Dockerfile push: false tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" - + - name: Confirm that we can run ACME php via docker + run: docker run --rm -it ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} phpstan: name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest From 2efd9255d38b31a3010287cf62cef3efab4d8cdd Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:49:36 +0200 Subject: [PATCH 58/77] chore: run container without tty --- .github/workflows/test-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 49532e7d..c9bba719 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -53,7 +53,7 @@ jobs: push: false tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" - name: Confirm that we can run ACME php via docker - run: docker run --rm -it ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} + run: docker run --rm ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} phpstan: name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest From a2b798bb58567152a8a4805a9c7bf9f5905fd1c8 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:51:43 +0200 Subject: [PATCH 59/77] chore: use fixed tag name --- .github/workflows/test-build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index c9bba719..c945ba48 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -51,9 +51,9 @@ jobs: context: build/ file: Dockerfile push: false - tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" + tags: acmephp - name: Confirm that we can run ACME php via docker - run: docker run --rm ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} + run: docker run --rm acmephp phpstan: name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest From cd3cce8fdadf7770623247f7b7bee5de3e936f71 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:57:07 +0200 Subject: [PATCH 60/77] chore: use buildx load --- .github/workflows/build-docker-master.yaml | 1 + .github/workflows/test-build.yaml | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker-master.yaml b/.github/workflows/build-docker-master.yaml index 32874ce0..ddd81827 100644 --- a/.github/workflows/build-docker-master.yaml +++ b/.github/workflows/build-docker-master.yaml @@ -31,6 +31,7 @@ jobs: context: build/ file: Dockerfile push: true + load: true tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" - name: Confirm that we can run ACME php via docker run: docker run --rm -it ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index c945ba48..34a98d8e 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -51,9 +51,10 @@ jobs: context: build/ file: Dockerfile push: false - tags: acmephp + load: true + tags: ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} - name: Confirm that we can run ACME php via docker - run: docker run --rm acmephp + run: docker run --rm ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} phpstan: name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} runs-on: ubuntu-latest From f41b7c6dca4a89ccda1d786640d832a72fe00fa9 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 15:59:00 +0200 Subject: [PATCH 61/77] chore: use git tag with valid number --- .github/workflows/test-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 34a98d8e..34058470 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: git tag ci + - run: git tag "0.0.0" - name: Setup PHP uses: shivammathur/setup-php@v2 with: From e4adb4415dbe120b6a5c43c7ad55747fdb26ff31 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 16:07:26 +0200 Subject: [PATCH 62/77] chore: try full checkout instead of manual tag --- .github/workflows/build-docker-master.yaml | 2 ++ .github/workflows/test-build.yaml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-master.yaml b/.github/workflows/build-docker-master.yaml index ddd81827..171561da 100644 --- a/.github/workflows/build-docker-master.yaml +++ b/.github/workflows/build-docker-master.yaml @@ -9,6 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 with: diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 34058470..4e5c020a 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -28,7 +28,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: git tag "0.0.0" + with: + fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 with: From 74b4e47faaff47eeaf8089bbc5b5656264ef0753 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 15 Aug 2024 16:11:23 +0200 Subject: [PATCH 63/77] fix(ci): dont run with tty --- .github/workflows/build-docker-master.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-master.yaml b/.github/workflows/build-docker-master.yaml index 171561da..ea000eb1 100644 --- a/.github/workflows/build-docker-master.yaml +++ b/.github/workflows/build-docker-master.yaml @@ -36,7 +36,7 @@ jobs: load: true tags: "ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }}" - name: Confirm that we can run ACME php via docker - run: docker run --rm -it ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} + run: docker run --rm ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} permissions: packages: write contents: read From e3d456010cdd0151539d0fa4ce0ce747983e72a3 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 10 Jan 2023 12:34:37 +0200 Subject: [PATCH 64/77] Rewrite Gandi soulver to support wildcard domains --- src/Core/Challenge/Dns/GandiSolver.php | 86 ++++++++++++++++---------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/src/Core/Challenge/Dns/GandiSolver.php b/src/Core/Challenge/Dns/GandiSolver.php index eb52c0a0..1d5e39a4 100644 --- a/src/Core/Challenge/Dns/GandiSolver.php +++ b/src/Core/Challenge/Dns/GandiSolver.php @@ -76,30 +76,26 @@ public function solve(AuthorizationChallenge $authorizationChallenge) public function solveAll(array $authorizationChallenges) { - Assert::allIsInstanceOf($authorizationChallenges, AuthorizationChallenge::class); - - foreach ($authorizationChallenges as $authorizationChallenge) { - $topLevelDomain = $this->getTopLevelDomain($authorizationChallenge->getDomain()); - $recordName = $this->extractor->getRecordName($authorizationChallenge); - $recordValue = $this->extractor->getRecordValue($authorizationChallenge); - - $subDomain = \str_replace('.'.$topLevelDomain.'.', '', $recordName); - - $this->client->request( - 'PUT', - 'https://dns.api.gandi.net/api/v5/domains/'.$topLevelDomain.'/records/'.$subDomain.'/TXT', - [ - 'headers' => [ - 'X-Api-Key' => $this->apiKey, - ], - 'json' => [ - 'rrset_type' => 'TXT', - 'rrset_ttl' => 600, - 'rrset_name' => $subDomain, - 'rrset_values' => [$recordValue], - ], - ] - ); + $apiData = $this->prepareDataForAPICalls($authorizationChallenges); + + foreach ($apiData as $topLevelDomain => $subDomains) { + foreach ($subDomains as $subDomain => $recordValues) { + $this->client->request( + 'PUT', + 'https://dns.api.gandi.net/api/v5/domains/'.$topLevelDomain.'/records/'.$subDomain.'/TXT', + [ + 'headers' => [ + 'X-Api-Key' => $this->apiKey, + ], + 'json' => [ + 'rrset_type' => 'TXT', + 'rrset_ttl' => 600, + 'rrset_name' => $subDomain, + 'rrset_values' => $recordValues, + ], + ] + ); + } } } @@ -109,25 +105,49 @@ public function cleanup(AuthorizationChallenge $authorizationChallenge) } public function cleanupAll(array $authorizationChallenges) + { + $apiData = $this->prepareDataForAPICalls($authorizationChallenges); + + foreach ($apiData as $topLevelDomain => $subDomains) { + foreach (\array_keys($subDomains) as $subDomain) { + $this->client->request( + 'DELETE', + 'https://dns.api.gandi.net/api/v5/domains/'.$topLevelDomain.'/records/'.$subDomain.'/TXT', + [ + 'headers' => [ + 'X-Api-Key' => $this->apiKey, + ], + ] + ); + } + } + } + + public function prepareDataForAPICalls(array $authorizationChallenges) { Assert::allIsInstanceOf($authorizationChallenges, AuthorizationChallenge::class); + $apiData = []; + foreach ($authorizationChallenges as $authorizationChallenge) { $topLevelDomain = $this->getTopLevelDomain($authorizationChallenge->getDomain()); $recordName = $this->extractor->getRecordName($authorizationChallenge); + $recordValue = $this->extractor->getRecordValue($authorizationChallenge); $subDomain = \str_replace('.'.$topLevelDomain.'.', '', $recordName); - $this->client->request( - 'DELETE', - 'https://dns.api.gandi.net/api/v5/domains/'.$topLevelDomain.'/records/'.$subDomain.'/TXT', - [ - 'headers' => [ - 'X-Api-Key' => $this->apiKey, - ], - ] - ); + if (!\array_key_exists($topLevelDomain, $apiData)) { + $apiData[$topLevelDomain] = []; + } + + if (!\array_key_exists($subDomain, $apiData[$topLevelDomain])) { + $apiData[$topLevelDomain][$subDomain] = []; + } + + $apiData[$topLevelDomain][$subDomain][] = $recordValue; } + + return $apiData; } protected function getTopLevelDomain(string $domain): string From 6e0f24da89e1c48f96e59ae17a27eabeeb722e74 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Fri, 16 Aug 2024 14:28:44 +0200 Subject: [PATCH 65/77] chore(ci): upload phar file artifact for testing --- .github/workflows/test-build.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 4e5c020a..249bb14f 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -7,6 +7,28 @@ on: - master jobs: + create_phar: + name: Create phar + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: box + - uses: ramsey/composer-install@v3 + - name: Build PHAR + run: box compile + - uses: actions/upload-artifact@v4 + with: + name: amcephp.phar + path: build/acmephp.phar + if-no-files-found: error + overwrite: true + php-cs: name: PHP-CS-Fixer runs-on: ubuntu-latest From 88adf0a160955558b68ed294c6d404631ff510a6 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Fri, 16 Aug 2024 14:36:37 +0200 Subject: [PATCH 66/77] chore(ci): put link in comment --- .github/workflows/pr-phar.yaml | 31 +++++++++++++++++++++++++++++++ .github/workflows/test-build.yaml | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/pr-phar.yaml diff --git a/.github/workflows/pr-phar.yaml b/.github/workflows/pr-phar.yaml new file mode 100644 index 00000000..bff425d6 --- /dev/null +++ b/.github/workflows/pr-phar.yaml @@ -0,0 +1,31 @@ +name: Create phar +on: + pull_request: +jobs: + create_phar: + name: Create phar + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: box + - uses: ramsey/composer-install@v3 + - name: Build PHAR + run: box compile + - uses: actions/upload-artifact@v4 + with: + name: amcephp.phar + path: build/acmephp.phar + if-no-files-found: error + overwrite: true + - uses: mshick/add-pr-comment@v2 + with: + message: | + We have created a phar file for testing, find it here: ${{ steps.artifact-upload-step.outputs.artifact-url }} diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 249bb14f..e212242d 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -28,6 +28,8 @@ jobs: path: build/acmephp.phar if-no-files-found: error overwrite: true + - name: Output artifact ID + run: echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}' php-cs: name: PHP-CS-Fixer From 2c15112322fb740d58b8e07b6f2694c30b189cd0 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Fri, 16 Aug 2024 14:39:32 +0200 Subject: [PATCH 67/77] chore(ci): clean up fix output name --- .github/workflows/pr-phar.yaml | 3 ++- .github/workflows/test-build.yaml | 24 ------------------------ 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pr-phar.yaml b/.github/workflows/pr-phar.yaml index bff425d6..95ad4598 100644 --- a/.github/workflows/pr-phar.yaml +++ b/.github/workflows/pr-phar.yaml @@ -20,6 +20,7 @@ jobs: - name: Build PHAR run: box compile - uses: actions/upload-artifact@v4 + id: artifact-upload with: name: amcephp.phar path: build/acmephp.phar @@ -28,4 +29,4 @@ jobs: - uses: mshick/add-pr-comment@v2 with: message: | - We have created a phar file for testing, find it here: ${{ steps.artifact-upload-step.outputs.artifact-url }} + We have created a phar file for testing, find it here: ${{ steps.artifact-upload.outputs.artifact-url }} diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index e212242d..4e5c020a 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -7,30 +7,6 @@ on: - master jobs: - create_phar: - name: Create phar - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - tools: box - - uses: ramsey/composer-install@v3 - - name: Build PHAR - run: box compile - - uses: actions/upload-artifact@v4 - with: - name: amcephp.phar - path: build/acmephp.phar - if-no-files-found: error - overwrite: true - - name: Output artifact ID - run: echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}' - php-cs: name: PHP-CS-Fixer runs-on: ubuntu-latest From 7f4e6406ba7f6870a73f23889580ccdc8542912a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 21 Aug 2024 11:00:41 +0200 Subject: [PATCH 68/77] Fix serializer --- .github/workflows/test-build.yaml | 2 +- phpstan-baseline.neon | 5 ----- src/Cli/Resources/services.xml | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml index 4e5c020a..e2290e95 100644 --- a/.github/workflows/test-build.yaml +++ b/.github/workflows/test-build.yaml @@ -57,7 +57,7 @@ jobs: - name: Confirm that we can run ACME php via docker run: docker run --rm ghcr.io/${{ github.repository }}/acmephp:master-${{ github.sha }} phpstan: - name: Test PHP ${{ matrix.php-version }} ${{ matrix.name }} + name: PHPStan runs-on: ubuntu-latest steps: - uses: shivammathur/setup-php@v2 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 53c9bea1..8ea5f4dd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -105,11 +105,6 @@ parameters: count: 2 path: src/Core/AcmeClient.php - - - message: "#^Offset 'finalize' does not exist on array\\|string\\.$#" - count: 2 - path: src/Core/AcmeClient.php - - message: "#^Offset 'identifier' does not exist on array\\|string\\.$#" count: 2 diff --git a/src/Cli/Resources/services.xml b/src/Cli/Resources/services.xml index d939d50b..b518bc07 100644 --- a/src/Cli/Resources/services.xml +++ b/src/Cli/Resources/services.xml @@ -53,14 +53,14 @@ - + - + From c8f3198250a15e6f483438142475e7b5bcbdf43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 21 Aug 2024 11:31:23 +0200 Subject: [PATCH 69/77] Relax constraint on psr/http-message and psr/container --- CHANGELOG.md | 11 +++++++---- composer.json | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7251c4e..43cac332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,16 +9,19 @@ * Add support for lcobucci/jwt ^5.3 * Add support for guzzlehttp/psr7 ^2.4 +* Add support for psr/http-message ^2 +* Add support for psr/container ^2 +* Add support for psr/log ^2 || ^3 ### BC Break -* Drop support for PHP <8.3 -* Drop support for Symfony <5.4, and 6.0, 6.1, 6.2, 6.3 +* Drop support for PHP < 8.3 +* Drop support for Symfony < 5.4, and 6.0, 6.1, 6.2, 6.3 * Drop support for lcobucci/jwt < 5.3 * Drop support for guzzlehttp/psr7 < 2 * Upgrade from FlySystem v1 to v3 -* Drop support for monolog ^1 -* Drop support for psr/log ^1 +* Drop support for monolog < 3 +* Drop support for psr/log < 2 ### Internal diff --git a/composer.json b/composer.json index f27d0a98..145c543f 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,8 @@ "league/flysystem-memory": "^3.10", "league/flysystem-sftp-v3": "^3.10", "monolog/monolog": "^3", - "psr/container": "^1.0", - "psr/http-message": "^1.0", + "psr/container": "^1 || ^2", + "psr/http-message": "^1 || ^2", "psr/log": "^2 || ^3", "symfony/config": "^5.4.12 || ^6.4", "symfony/console": "^5.4.12 || ^6.4", From e63ef396cc67790e5a2a247ba016671b4bf196a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 21 Aug 2024 12:19:37 +0200 Subject: [PATCH 70/77] Fixed type hinting --- src/Cli/Monolog/ConsoleHandler.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Cli/Monolog/ConsoleHandler.php b/src/Cli/Monolog/ConsoleHandler.php index a6cec9e7..b1938b6f 100644 --- a/src/Cli/Monolog/ConsoleHandler.php +++ b/src/Cli/Monolog/ConsoleHandler.php @@ -22,7 +22,7 @@ * * Extracted from Symfony Monolog bridge. * - * @see https://github.com/symfony/monolog-bridge/edit/master/Handler/ConsoleHandler.php + * @see https://github.com/symfony/monolog-bridge/blob/7.1/Handler/ConsoleHandler.php * * @author Tobias Schultze */ @@ -40,8 +40,6 @@ class ConsoleHandler extends AbstractProcessingHandler ]; /** - * Constructor. - * * @param OutputInterface|null $output The console output to use (the handler remains disabled when passing null * until the output is set, e.g. by using console events) * @param bool $bubble Whether the messages that are handled can bubble up the stack @@ -71,8 +69,6 @@ public function handle(LogRecord $record): bool /** * Sets the console output to use for printing logs. - * - * @param OutputInterface $output The console output to use */ public function setOutput(OutputInterface $output): void { @@ -89,9 +85,9 @@ public function close(): void parent::close(); } - protected function write(LogRecord|array $record): void + protected function write(LogRecord $record): void { - $this->output->write((string) $record['formatted']); + $this->output->write((string) $record->formatted); } protected function getDefaultFormatter(): FormatterInterface From 423fe2f58ae6dbc41b2d222ece73e2bea7739473 Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Wed, 21 Aug 2024 13:01:36 +0200 Subject: [PATCH 71/77] chore(ci): allow pr comment from fork prs --- .github/workflows/pr-phar.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-phar.yaml b/.github/workflows/pr-phar.yaml index 95ad4598..e4e986f1 100644 --- a/.github/workflows/pr-phar.yaml +++ b/.github/workflows/pr-phar.yaml @@ -1,6 +1,6 @@ name: Create phar on: - pull_request: + pull_request_target: jobs: create_phar: name: Create phar From 338f53a0476b261ada3814823d959d6d16611736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 21 Aug 2024 12:02:29 +0200 Subject: [PATCH 72/77] Add support for symfony ^7.1 --- CHANGELOG.md | 1 + composer.json | 22 +++++++++++----------- phpstan-baseline.neon | 5 ----- src/Cli/Serializer/PemEncoder.php | 8 ++++---- src/Cli/Serializer/PemNormalizer.php | 8 ++++---- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7251c4e..bca6f7bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Add support for lcobucci/jwt ^5.3 * Add support for guzzlehttp/psr7 ^2.4 +* Add support for symfony ^7.1 ### BC Break diff --git a/composer.json b/composer.json index f27d0a98..72fbc7b6 100644 --- a/composer.json +++ b/composer.json @@ -55,20 +55,20 @@ "psr/container": "^1.0", "psr/http-message": "^1.0", "psr/log": "^2 || ^3", - "symfony/config": "^5.4.12 || ^6.4", - "symfony/console": "^5.4.12 || ^6.4", - "symfony/dependency-injection": "^5.4.12 || ^6.4", - "symfony/filesystem": "^5.4.12 || ^6.4", - "symfony/serializer": "^5.4.12 || ^6.4", - "symfony/yaml": "^5.4.12 || ^6.4", + "symfony/config": "^5.4.12 || ^6.4 || ^7.1", + "symfony/console": "^5.4.12 || ^6.4 || ^7.1", + "symfony/dependency-injection": "^5.4.12 || ^6.4 || ^7.1", + "symfony/filesystem": "^5.4.12 || ^6.4 || ^7.1", + "symfony/serializer": "^5.4.12 || ^6.4 || ^7.1", + "symfony/yaml": "^5.4.12 || ^6.4 || ^7.1", "webmozart/assert": "^1.0" }, "require-dev": { - "phpstan/phpstan": "^1.11", - "symfony/finder": "^5.4.12 || ^6.4", - "symfony/phpunit-bridge": "^5.4.12 || ^6.4", - "symfony/property-access": "^5.4.12 || ^6.4", - "symfony/var-dumper": "^5.4.12 || ^6.4" + "phpstan/phpstan": "^1.11.11", + "symfony/finder": "^5.4.12 || ^6.4 || ^7.1", + "symfony/phpunit-bridge": "^5.4.12 || ^6.4 || ^7.1", + "symfony/property-access": "^5.4.12 || ^6.4 || ^7.1", + "symfony/var-dumper": "^5.4.12 || ^6.4 || ^7.1" }, "autoload": { "psr-4": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8ea5f4dd..73d04f7c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -85,11 +85,6 @@ parameters: count: 1 path: src/Cli/Repository/Repository.php - - - message: "#^Method AcmePhp\\\\Cli\\\\Serializer\\\\PemNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" - count: 1 - path: src/Cli/Serializer/PemNormalizer.php - - message: "#^Method AcmePhp\\\\Core\\\\AcmeClient\\:\\:registerAccount\\(\\) should return array but returns array\\|string\\.$#" count: 1 diff --git a/src/Cli/Serializer/PemEncoder.php b/src/Cli/Serializer/PemEncoder.php index e1f0a459..94e52613 100644 --- a/src/Cli/Serializer/PemEncoder.php +++ b/src/Cli/Serializer/PemEncoder.php @@ -21,22 +21,22 @@ class PemEncoder implements EncoderInterface, DecoderInterface { public const FORMAT = 'pem'; - public function encode($data, $format, array $context = []): string + public function encode(mixed $data, string $format, array $context = []): string { return trim($data)."\n"; } - public function decode($data, $format, array $context = []) + public function decode(string $data, string $format, array $context = []): string { return trim($data)."\n"; } - public function supportsEncoding($format): bool + public function supportsEncoding(string $format): bool { return self::FORMAT === $format; } - public function supportsDecoding($format) + public function supportsDecoding(string $format): bool { return self::FORMAT === $format; } diff --git a/src/Cli/Serializer/PemNormalizer.php b/src/Cli/Serializer/PemNormalizer.php index 0b9f8f57..984c022f 100644 --- a/src/Cli/Serializer/PemNormalizer.php +++ b/src/Cli/Serializer/PemNormalizer.php @@ -21,22 +21,22 @@ */ class PemNormalizer implements NormalizerInterface, DenormalizerInterface { - public function normalize($object, ?string $format = null, array $context = []) + public function normalize(mixed $object, ?string $format = null, array $context = []): string { return $object->getPEM(); } - public function denormalize($data, $class, ?string $format = null, array $context = []) + public function denormalize(mixed $data, string $class, ?string $format = null, array $context = []): object { return new $class($data); } - public function supportsNormalization($data, ?string $format = null) + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return \is_object($data) && ($data instanceof Certificate || $data instanceof Key); } - public function supportsDenormalization($data, $type, ?string $format = null) + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { return \is_string($data); } From 26e64e54fb8bc2f1a3e453c815811d8e5256043d Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 21 Aug 2024 14:57:02 +0200 Subject: [PATCH 73/77] Update the badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ec35b55..114963dd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Acme PHP ======== -[![Build Status](https://img.shields.io/github/workflow/status/acmephp/acmephp/Test%20and%20build?style=flat-square)](https://github.com/acmephp/acmephp/actions?query=branch%3Amaster+workflow%3A%22Test+and+build%22) +[![Build Status](https://img.shields.io/github/actions/workflow/status/acmephp/acmephp/test-build.yaml?branch=master&style=flat-square)](https://github.com/acmephp/acmephp/actions/workflows/test-build.yaml?query=branch%3Amaster) [![Packagist Version](https://img.shields.io/packagist/v/acmephp/acmephp.svg?style=flat-square)](https://packagist.org/packages/acmephp/acmephp) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) From 69f210bc2f7f698c46c9721cfac794fbe8b52621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 21 Aug 2024 16:23:10 +0200 Subject: [PATCH 74/77] Sync all composer.json --- src/Core/composer.json | 9 ++++----- src/Ssl/composer.json | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Core/composer.json b/src/Core/composer.json index 615dc6a2..80f67104 100644 --- a/src/Core/composer.json +++ b/src/Core/composer.json @@ -32,12 +32,11 @@ "ext-json": "*", "ext-openssl": "*", "acmephp/ssl": "^2.0", - "guzzlehttp/guzzle": "^6.0|^7.0", - "guzzlehttp/psr7": "^1.7|^2.1", + "guzzlehttp/guzzle": "^7.2", + "guzzlehttp/psr7": "^2.4.5", "lcobucci/jwt": "^5.3", - "psr/http-client": "^1.0", - "psr/http-message": "^1.0", - "psr/log": "^1.0|^2.0|^3.0", + "psr/http-message": "^1 || ^2", + "psr/log": "^2 || ^3", "webmozart/assert": "^1.0" }, "autoload": { diff --git a/src/Ssl/composer.json b/src/Ssl/composer.json index da51c8ec..57b41d61 100644 --- a/src/Ssl/composer.json +++ b/src/Ssl/composer.json @@ -32,7 +32,7 @@ } }, "require": { - "php": ">=8.1", + "php": ">=8.3", "ext-hash": "*", "ext-openssl": "*", "lib-openssl": ">=0.9.8", From d8b27b17572791f5d60e2324f9cd62323b23b371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 22 Aug 2024 17:42:57 +0200 Subject: [PATCH 75/77] Reword a bit the changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ec21f3..fc31099e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## 3.0.0 (not released yet) +## 2.2.0 (not released yet) > [!NOTE] > From now on, a particular attention will be given to provide a nice changelog. @@ -14,7 +14,7 @@ * Add support for psr/container ^2 * Add support for psr/log ^2 || ^3 -### BC Break +### End of support * Drop support for PHP < 8.3 * Drop support for Symfony < 5.4, and 6.0, 6.1, 6.2, 6.3 From 70f32569b5fb8b88727a51699bfc49294b5cf64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 13 Nov 2024 10:33:35 +0100 Subject: [PATCH 76/77] Add support for consolidation/self-update ^2.2 || ^3 This unlock full support for SF 7.1 --- CHANGELOG.md | 1 + composer.json | 2 +- phpstan-baseline.neon | 5 ----- src/Cli/Application.php | 11 ++++++++++- src/Cli/Command/AbstractCommand.php | 2 +- src/Cli/Command/Helper/DistinguishedNameHelper.php | 2 +- src/Cli/Command/RevokeCommand.php | 10 +++++----- src/Cli/Command/RunCommand.php | 4 ++-- src/Cli/Command/StatusCommand.php | 4 ++-- src/Cli/Configuration/DomainConfiguration.php | 2 +- 10 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc31099e..004e9c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Add support for psr/http-message ^2 * Add support for psr/container ^2 * Add support for psr/log ^2 || ^3 +* Add support for consolidation/self-update ^2.2 || ^3 ### End of support diff --git a/composer.json b/composer.json index 873d5822..a6736502 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "alibabacloud/cdn": "^1.7", "alibabacloud/wafopenapi": "^1.7", "aws/aws-sdk-php": "^3.38", - "consolidation/self-update": "^2.2", + "consolidation/self-update": "^2.2 || ^3", "guzzlehttp/guzzle": "^7.2", "guzzlehttp/psr7": "^2.4.5", "lcobucci/jwt": "^5.3", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 73d04f7c..24d4273b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -25,11 +25,6 @@ parameters: count: 1 path: src/Cli/Command/AbstractCommand.php - - - message: "#^Method AcmePhp\\\\Cli\\\\Command\\\\RevokeCommand\\:\\:execute\\(\\) should return int but empty return statement found\\.$#" - count: 3 - path: src/Cli/Command/RevokeCommand.php - - message: "#^Access to an undefined property object\\:\\:\\$eab_hmac_key\\.$#" count: 2 diff --git a/src/Cli/Application.php b/src/Cli/Application.php index 7dbb087b..58ecbb8e 100644 --- a/src/Cli/Application.php +++ b/src/Cli/Application.php @@ -16,6 +16,7 @@ use AcmePhp\Cli\Command\RunCommand; use AcmePhp\Cli\Command\StatusCommand; use SelfUpdate\SelfUpdateCommand; +use SelfUpdate\SelfUpdateManager; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Filesystem\Path; @@ -41,11 +42,19 @@ protected function getDefaultCommands(): array { $version = explode('@', $this->getVersion())[0]; + if (class_exists(SelfUpdateManager::class)) { + $selfUpdateCommand = new SelfUpdateCommand(new SelfUpdateManager($this->getName(), '' === $version ? '0.0.0' : $version, 'acmephp/acmephp')); + } else { + // Support for older versions of the self-update package + // @phpstan-ignore-next-line + $selfUpdateCommand = new SelfUpdateCommand($this->getName(), '' === $version ? '0.0.0' : $version, 'acmephp/acmephp'); + } + return array_merge(parent::getDefaultCommands(), [ new RunCommand(), new RevokeCommand(), new StatusCommand(), - new SelfUpdateCommand($this->getName(), '' === $version ? '0.0.0' : $version, 'acmephp/acmephp'), + $selfUpdateCommand, ]); } diff --git a/src/Cli/Command/AbstractCommand.php b/src/Cli/Command/AbstractCommand.php index 356561d4..8d27d6e6 100644 --- a/src/Cli/Command/AbstractCommand.php +++ b/src/Cli/Command/AbstractCommand.php @@ -47,7 +47,7 @@ abstract class AbstractCommand extends Command */ private $container; - protected function initialize(InputInterface $input, OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output): void { $this->input = $input; $this->output = $output; diff --git a/src/Cli/Command/Helper/DistinguishedNameHelper.php b/src/Cli/Command/Helper/DistinguishedNameHelper.php index 5b0452b7..daa964da 100644 --- a/src/Cli/Command/Helper/DistinguishedNameHelper.php +++ b/src/Cli/Command/Helper/DistinguishedNameHelper.php @@ -23,7 +23,7 @@ */ class DistinguishedNameHelper extends Helper { - public function getName() + public function getName(): string { return 'distinguished_name'; } diff --git a/src/Cli/Command/RevokeCommand.php b/src/Cli/Command/RevokeCommand.php index 18e4e227..c6e0fa02 100644 --- a/src/Cli/Command/RevokeCommand.php +++ b/src/Cli/Command/RevokeCommand.php @@ -21,7 +21,7 @@ class RevokeCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $reasons = implode(PHP_EOL, RevocationReason::getFormattedReasons()); @@ -41,7 +41,7 @@ protected function configure() ->setHelp('The %command.name% command revoke a previously obtained certificate for a given domain'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if (!isset(Application::PROVIDERS[$this->input->getOption('provider')])) { throw new \InvalidArgumentException('Invalid provider, supported: '.implode(', ', Application::PROVIDERS)); @@ -58,13 +58,13 @@ protected function execute(InputInterface $input, OutputInterface $output) } catch (\InvalidArgumentException $e) { $this->error('Reason code must be one of: '.PHP_EOL.implode(PHP_EOL, RevocationReason::getFormattedReasons())); - return; + return 1; } if (!$repository->hasDomainCertificate($domain)) { $this->error('Certificate for '.$domain.' not found locally'); - return; + return 1; } $certificate = $repository->loadDomainCertificate($domain); @@ -74,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } catch (CertificateRevocationException $e) { $this->error($e->getMessage()); - return; + return 1; } $this->notice('Certificate revoked successfully!'); diff --git a/src/Cli/Command/RunCommand.php b/src/Cli/Command/RunCommand.php index 87e1db3f..8bdd7b72 100644 --- a/src/Cli/Command/RunCommand.php +++ b/src/Cli/Command/RunCommand.php @@ -50,7 +50,7 @@ class RunCommand extends AbstractCommand private $config; - protected function configure() + protected function configure(): void { $this->setName('run') ->setDefinition( @@ -69,7 +69,7 @@ protected function configure() ->setHelp('The %command.name% challenge the domains, request the certificates and install them following a given configuration.'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $cwd = getcwd(); if (false === $cwd) { diff --git a/src/Cli/Command/StatusCommand.php b/src/Cli/Command/StatusCommand.php index 0838e0c4..a1cfbae7 100644 --- a/src/Cli/Command/StatusCommand.php +++ b/src/Cli/Command/StatusCommand.php @@ -23,7 +23,7 @@ */ class StatusCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { $this->setName('status') ->setDescription('List all the certificates handled by Acme PHP') @@ -35,7 +35,7 @@ protected function configure() ); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $repository = $this->getRepository(); diff --git a/src/Cli/Configuration/DomainConfiguration.php b/src/Cli/Configuration/DomainConfiguration.php index 251bde9f..4add46eb 100644 --- a/src/Cli/Configuration/DomainConfiguration.php +++ b/src/Cli/Configuration/DomainConfiguration.php @@ -20,7 +20,7 @@ */ class DomainConfiguration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('acmephp'); if (method_exists(TreeBuilder::class, 'getRootNode')) { From c35219954f23274af863789bb55fb6f1e1054e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 13 Nov 2024 11:31:31 +0100 Subject: [PATCH 77/77] Lock phpstan/phpdoc-parser to v1 in test Symfony is not compatible with v2 yet --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 46e21548..a05da4c4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,7 +14,7 @@ - +