Skip to content

Commit 5989b09

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix tests regarding OpenSSL security_level
2 parents ed6fbf9 + b281493 commit 5989b09

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

ext/openssl/tests/tls_min_v1.0_max_v1.1_wrapper.phpt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ $certFile = __DIR__ . DIRECTORY_SEPARATOR . 'tls_min_v1.0_max_v1.1_wrapper.pem.t
1111

1212
$serverCode = <<<'CODE'
1313
$flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
14-
$ctx = stream_context_create(['ssl' => [
14+
$ssl_opts = [
1515
'local_cert' => '%s',
1616
'min_proto_version' => STREAM_CRYPTO_PROTO_TLSv1_0,
1717
'max_proto_version' => STREAM_CRYPTO_PROTO_TLSv1_1,
18-
'security_level' => 1,
19-
]]);
18+
];
19+
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
20+
$ssl_opts['security_level'] = 1;
21+
}
22+
$ctx = stream_context_create(['ssl' => $ssl_opts]);
2023
2124
$server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
2225
phpt_notify();
@@ -29,11 +32,14 @@ $serverCode = sprintf($serverCode, $certFile);
2932

3033
$clientCode = <<<'CODE'
3134
$flags = STREAM_CLIENT_CONNECT;
32-
$ctx = stream_context_create(['ssl' => [
35+
$ssl_opts = [
3336
'verify_peer' => false,
3437
'verify_peer_name' => false,
35-
'security_level' => 1,
36-
]]);
38+
];
39+
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
40+
$ssl_opts['security_level'] = 1;
41+
}
42+
$ctx = stream_context_create(['ssl' => $ssl_opts]);
3743
3844
phpt_wait();
3945

ext/openssl/tests/tlsv1.0_wrapper.phpt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ $certFile = __DIR__ . DIRECTORY_SEPARATOR . 'tlsv1.0_wrapper.pem.tmp';
1111

1212
$serverCode = <<<'CODE'
1313
$flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
14-
$ctx = stream_context_create(['ssl' => [
14+
$ssl_opts = [
1515
'local_cert' => '%s',
16-
'security_level' => 1,
17-
]]);
16+
];
17+
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
18+
$ssl_opts['security_level'] = 1;
19+
}
20+
$ctx = stream_context_create(['ssl' => $ssl_opts]);
1821
1922
$server = stream_socket_server('tlsv1.0://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
2023
phpt_notify();
@@ -27,11 +30,14 @@ $serverCode = sprintf($serverCode, $certFile);
2730

2831
$clientCode = <<<'CODE'
2932
$flags = STREAM_CLIENT_CONNECT;
30-
$ctx = stream_context_create(['ssl' => [
33+
$ssl_opts = [
3134
'verify_peer' => false,
3235
'verify_peer_name' => false,
33-
'security_level' => 1,
34-
]]);
36+
];
37+
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
38+
$ssl_opts['security_level'] = 1;
39+
}
40+
$ctx = stream_context_create(['ssl' => $ssl_opts]);
3541
3642
phpt_wait();
3743

ext/openssl/tests/tlsv1.1_wrapper.phpt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ $certFile = __DIR__ . DIRECTORY_SEPARATOR . 'tlsv1.1_wrapper.pem.tmp';
1111

1212
$serverCode = <<<'CODE'
1313
$flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
14-
$ctx = stream_context_create(['ssl' => [
14+
$ssl_opts = [
1515
'local_cert' => '%s',
16-
'security_level' => 1,
17-
]]);
16+
];
17+
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
18+
$ssl_opts['security_level'] = 1;
19+
}
20+
$ctx = stream_context_create(['ssl' => $ssl_opts]);
1821
1922
$server = stream_socket_server('tlsv1.1://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
2023
phpt_notify();
@@ -27,11 +30,14 @@ $serverCode = sprintf($serverCode, $certFile);
2730

2831
$clientCode = <<<'CODE'
2932
$flags = STREAM_CLIENT_CONNECT;
30-
$ctx = stream_context_create(['ssl' => [
33+
$ssl_opts = [
3134
'verify_peer' => false,
3235
'verify_peer_name' => false,
33-
'security_level' => 1,
34-
]]);
36+
];
37+
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
38+
$ssl_opts['security_level'] = 1;
39+
}
40+
$ctx = stream_context_create(['ssl' => $ssl_opts]);
3541
3642
phpt_wait();
3743

0 commit comments

Comments
 (0)