Skip to content

Commit c96ed07

Browse files
committed
skip openssl 3.0
1 parent 3c9b8f4 commit c96ed07

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/Symmetric/OpensslCipher.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,17 @@ class OpensslCipher implements CipherInterface
6464
*/
6565
public function __construct(string $method, array $options = [])
6666
{
67-
if (!is_callable('openssl_encrypt')) {
67+
if (!function_exists('openssl_encrypt')) {
6868
throw new CryptException('The openssl extension is not available.');
6969
}
7070

71+
// Openssl 3.0 no longer support legacy unsafe cipher
72+
$version = explode(' ', OPENSSL_VERSION_TEXT)[1] ?? '';
73+
74+
if (version_compare($version, '3.0', '>=')) {
75+
throw new CryptException('No-longer support openssl 3.0.');
76+
}
77+
7178
$this->options = array_merge(
7279
[
7380
'pbkdf2_iteration' => 12000,

test/Symmetric/LegacyOpensslCipherTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ class LegacyOpensslCipherTest extends TestCase
3030
*/
3131
protected $instance;
3232

33+
public static function setUpBeforeClass(): void
34+
{
35+
if (!function_exists('openssl_encrypt')) {
36+
self::markTestSkipped('No openssl installed.');
37+
}
38+
39+
// Openssl 3.0 no longer support legacy unsafe cipher
40+
$version = explode(' ', OPENSSL_VERSION_TEXT)[1] ?? '';
41+
42+
if (version_compare($version, '3.0', '>=')) {
43+
self::markTestSkipped('No-longer support openssl 3.0.');
44+
}
45+
}
46+
3347
/**
3448
* Sets up the fixture, for example, opens a network connection.
3549
* This method is called before a test is executed.
@@ -84,11 +98,10 @@ public function methodsLegacyProvider(): array
8498
'des-ede3-cbc',
8599
'vH8xcBwXQiXZ/YSvw+h0eWLbnftFHJNb5dc/Ob2vOHU=:MZIUaSKqBsnb0ZeMG5vJDzVwbyrrAPqYoqXNTO6RoUw=:/cEHJARlmjg=:fd0YQLROmEQRiEIyoOcXag==',
86100
],
87-
// Openssl 3.0 no longer support legacy unsafe cipher
88-
// 'bf-cbc' => [
89-
// 'bf-cbc',
90-
// '5ZTJ03ITnhshMxghJh/+b9d2+kSAPsGdHrcXXBp7Zso=:MS1jDSc5uxuf30ImrARNdXqn8oFexce+olpGj6PBbpA=:5WjBQfVXLuk=:S54cmXm3Lp3k42q7VRawVQ==',
91-
// ],
101+
'bf-cbc' => [
102+
'bf-cbc',
103+
'5ZTJ03ITnhshMxghJh/+b9d2+kSAPsGdHrcXXBp7Zso=:MS1jDSc5uxuf30ImrARNdXqn8oFexce+olpGj6PBbpA=:5WjBQfVXLuk=:S54cmXm3Lp3k42q7VRawVQ==',
104+
],
92105
];
93106
// phpcs:enable
94107
}

0 commit comments

Comments
 (0)