@@ -79,20 +79,27 @@ public function testVerifySignatureFail(): void
7979
8080 public function testGetCertificatesFromPkcs7Success ()
8181 {
82- $ leafHeader = 'subject=C = RO, ST = BUH, L = Bucuresti, O = Internet Widgits Pty Ltd, CN = leaflet ' .
83- PHP_EOL . 'issuer=C = RO, ST = BUH, O = PayU, CN = intermediate-cert ' . PHP_EOL ;
84- $ leafCert = file_get_contents (__DIR__ . '/leaf.crt ' );
85- $ intermediateHeader = 'subject=C = RO, ST = BUH, O = PayU, CN = intermediate-cert ' . PHP_EOL .
86- 'issuer=C = RO, ST = BUH, O = PayU ROOT, CN = root-cert ' . PHP_EOL ;
87- $ intermediateCert = file_get_contents (__DIR__ . '/intermediate.crt ' );
88-
89- $ expectedResponse = $ leafHeader . $ leafCert . PHP_EOL . PHP_EOL . $ intermediateHeader . $ intermediateCert ;
82+ $ leafCert = trim (file_get_contents (__DIR__ . '/leaf.crt ' ));
83+ $ intermediateCert = trim (file_get_contents (__DIR__ . '/intermediate.crt ' ));
9084
9185 $ pkcs7DerCert = realpath (__DIR__ . '/leaf.p7b ' );
9286
9387 $ response = $ this ->openSslService ->getCertificatesFromPkcs7 ($ pkcs7DerCert );
9488
95- $ this ->assertEquals ($ expectedResponse , $ response );
89+ // Assert subject/issuer headers are present for both certificates.
90+ // OpenSSL < 3.x formats as "C = RO", OpenSSL >= 3.x formats as "C=RO" — accept both.
91+ $ this ->assertMatchesRegularExpression (
92+ '/^subject=.*CN\s*=\s*leaflet\nissuer=.*CN\s*=\s*intermediate-cert\n/m ' ,
93+ $ response
94+ );
95+ $ this ->assertMatchesRegularExpression (
96+ '/^subject=.*CN\s*=\s*intermediate-cert\nissuer=.*CN\s*=\s*root-cert\n/m ' ,
97+ $ response
98+ );
99+
100+ // Assert both PEM certificate bodies are present verbatim.
101+ $ this ->assertStringContainsString ($ leafCert , $ response );
102+ $ this ->assertStringContainsString ($ intermediateCert , $ response );
96103 }
97104
98105 public function testGetCertificatesFromPkcs7Fail ()
0 commit comments