Skip to content

Commit 4f0ae4a

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 5989b09 + 2c0d47c commit 4f0ae4a

File tree

4 files changed

+19
-41
lines changed

4 files changed

+19
-41
lines changed

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ $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-
$ssl_opts = [
14+
$ctx = stream_context_create(['ssl' => [
1515
'local_cert' => '%s',
1616
'min_proto_version' => STREAM_CRYPTO_PROTO_TLSv1_0,
1717
'max_proto_version' => STREAM_CRYPTO_PROTO_TLSv1_1,
18-
];
19-
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
20-
$ssl_opts['security_level'] = 1;
21-
}
22-
$ctx = stream_context_create(['ssl' => $ssl_opts]);
18+
'security_level' => 1,
19+
]]);
2320
2421
$server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
2522
phpt_notify();
@@ -32,14 +29,11 @@ $serverCode = sprintf($serverCode, $certFile);
3229

3330
$clientCode = <<<'CODE'
3431
$flags = STREAM_CLIENT_CONNECT;
35-
$ssl_opts = [
32+
$ctx = stream_context_create(['ssl' => [
3633
'verify_peer' => false,
3734
'verify_peer_name' => false,
38-
];
39-
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
40-
$ssl_opts['security_level'] = 1;
41-
}
42-
$ctx = stream_context_create(['ssl' => $ssl_opts]);
35+
'security_level' => 1,
36+
]]);
4337
4438
phpt_wait();
4539

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

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

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

3128
$clientCode = <<<'CODE'
3229
$flags = STREAM_CLIENT_CONNECT;
33-
$ssl_opts = [
30+
$ctx = stream_context_create(['ssl' => [
3431
'verify_peer' => false,
3532
'verify_peer_name' => false,
36-
];
37-
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
38-
$ssl_opts['security_level'] = 1;
39-
}
40-
$ctx = stream_context_create(['ssl' => $ssl_opts]);
33+
'security_level' => 1,
34+
]]);
4135
4236
phpt_wait();
4337

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

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

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

3128
$clientCode = <<<'CODE'
3229
$flags = STREAM_CLIENT_CONNECT;
33-
$ssl_opts = [
30+
$ctx = stream_context_create(['ssl' => [
3431
'verify_peer' => false,
3532
'verify_peer_name' => false,
36-
];
37-
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
38-
$ssl_opts['security_level'] = 1;
39-
}
40-
$ctx = stream_context_create(['ssl' => $ssl_opts]);
33+
'security_level' => 1,
34+
]]);
4135
4236
phpt_wait();
4337

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,16 +1709,12 @@ int php_openssl_setup_crypto(php_stream *stream,
17091709
}
17101710

17111711
if (GET_VER_OPT("security_level")) {
1712-
#ifdef HAVE_SEC_LEVEL
17131712
zend_long lval = zval_get_long(val);
17141713
if (lval < 0 || lval > 5) {
17151714
php_error_docref(NULL, E_WARNING, "Security level must be between 0 and 5");
17161715
}
1716+
#ifdef HAVE_SEC_LEVEL
17171717
SSL_CTX_set_security_level(sslsock->ctx, lval);
1718-
#else
1719-
php_error_docref(NULL, E_WARNING,
1720-
"security_level is not supported by the linked OpenSSL library "
1721-
"- it is supported from version 1.1.0");
17221718
#endif
17231719
}
17241720

0 commit comments

Comments
 (0)