diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 485c1cb..4f29122 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -18,6 +18,10 @@ jobs: - 7.4 - 8.0 - 8.1 + - 8.2 + - 8.3 + - 8.4 + - 8.5 steps: - name: Checkout diff --git a/.github/workflows/phpunit-unit.yml b/.github/workflows/phpunit-unit.yml index 65518ef..5dba465 100644 --- a/.github/workflows/phpunit-unit.yml +++ b/.github/workflows/phpunit-unit.yml @@ -18,6 +18,10 @@ jobs: - 7.4 - 8.0 - 8.1 + - 8.2 + - 8.3 + - 8.4 + - 8.5 steps: - name: Checkout diff --git a/composer.json b/composer.json index feec01a..ac0cb42 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "ext-openssl": "*", "phpseclib/phpseclib": "^3.0", "spomky-labs/php-aes-gcm": "^1.2", - "symfony/process": "^4.1|^5.0|^6.0|^7.0" + "symfony/process": "^5.0|^6.0|^7.0" }, "require-dev": { "phpunit/phpunit": "^7.5|^9.0", diff --git a/tests/Decoding/OpenSSL/OpenSslServiceTest.php b/tests/Decoding/OpenSSL/OpenSslServiceTest.php index 109c958..3799ddc 100644 --- a/tests/Decoding/OpenSSL/OpenSslServiceTest.php +++ b/tests/Decoding/OpenSSL/OpenSslServiceTest.php @@ -79,20 +79,27 @@ public function testVerifySignatureFail(): void public function testGetCertificatesFromPkcs7Success() { - $leafHeader = 'subject=C = RO, ST = BUH, L = Bucuresti, O = Internet Widgits Pty Ltd, CN = leaflet' . - PHP_EOL . 'issuer=C = RO, ST = BUH, O = PayU, CN = intermediate-cert' . PHP_EOL; - $leafCert = file_get_contents(__DIR__ . '/leaf.crt'); - $intermediateHeader = 'subject=C = RO, ST = BUH, O = PayU, CN = intermediate-cert' . PHP_EOL . - 'issuer=C = RO, ST = BUH, O = PayU ROOT, CN = root-cert' . PHP_EOL; - $intermediateCert = file_get_contents(__DIR__ . '/intermediate.crt'); - - $expectedResponse = $leafHeader . $leafCert . PHP_EOL . PHP_EOL . $intermediateHeader . $intermediateCert; + $leafCert = trim(file_get_contents(__DIR__ . '/leaf.crt')); + $intermediateCert = trim(file_get_contents(__DIR__ . '/intermediate.crt')); $pkcs7DerCert = realpath(__DIR__ . '/leaf.p7b'); $response = $this->openSslService->getCertificatesFromPkcs7($pkcs7DerCert); - $this->assertEquals($expectedResponse, $response); + // Assert subject/issuer headers are present for both certificates. + // OpenSSL < 3.x formats as "C = RO", OpenSSL >= 3.x formats as "C=RO" — accept both. + $this->assertMatchesRegularExpression( + '/^subject=.*CN\s*=\s*leaflet\nissuer=.*CN\s*=\s*intermediate-cert\n/m', + $response + ); + $this->assertMatchesRegularExpression( + '/^subject=.*CN\s*=\s*intermediate-cert\nissuer=.*CN\s*=\s*root-cert\n/m', + $response + ); + + // Assert both PEM certificate bodies are present verbatim. + $this->assertStringContainsString($leafCert, $response); + $this->assertStringContainsString($intermediateCert, $response); } public function testGetCertificatesFromPkcs7Fail()