Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 10bc5fd

Browse files
committed
Fixed bug (#69195 Inconsistent stream crypto values across versions)
PHP 5.6.0 altered the semantics of the following constants: - STREAM_CRYPTO_METHOD_SSLv23_CLIENT - STREAM_CRYPTO_METHOD_SSLv23_SERVER - STREAM_CRYPTO_METHOD_TLS_CLIENT - STREAM_CRYPTO_METHOD_TLS_SERVER Instead of representing the SSLv23_*() handshake methods the v23 constants were changed to allow only SSLv2 or SSLv3 connections. Likewise, the TLS methods were modified from using only the TLSv1 handshake to allowing TLS1,1.1, and 1.2. This created a situation in which users upgrading from previous versions faced a potential security degradation if they did not update code to use different constants. In the interest of compatibility across PHP versions the original semantics have been restored with the following caveat: **IMPORTANT** The SSLv23 client/server methods will no longer negotiate the use of the insecure SSLv2 or SSLv3 protocols by default. Users wishing to allow these protocols must explicitly add them to the method bitmask via the appropriate flags.
1 parent e7df9d7 commit 10bc5fd

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
(Daniel Lowrey)
5858
. Fixed bug #68265 (SAN match fails with trailing DNS dot) (Daniel Lowrey)
5959
. Fixed bug #67403 (Add signatureType to openssl_x509_parse) (Daniel Lowrey)
60+
. Fixed bug (#69195 Inconsistent stream crypto values across versions)
61+
(Daniel Lowrey)
6062

6163
- pgsql:
6264
. Fixed bug #68638 (pg_update() fails to store infinite values).

ext/standard/http_fopen_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
323323

324324
/* enable SSL transport layer */
325325
if (stream) {
326-
if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_ANY_CLIENT, NULL TSRMLS_CC) < 0 ||
326+
if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
327327
php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) {
328328
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy");
329329
php_stream_close(stream);

main/streams/php_stream_transport.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,25 @@ typedef struct _php_stream_xport_param {
169169
typedef enum {
170170
STREAM_CRYPTO_METHOD_SSLv2_CLIENT = (1 << 1 | 1),
171171
STREAM_CRYPTO_METHOD_SSLv3_CLIENT = (1 << 2 | 1),
172-
STREAM_CRYPTO_METHOD_SSLv23_CLIENT = ((1 << 1) | (1 << 2) | 1),
172+
/* v23 no longer negotiates SSL2 or SSL3 */
173+
STREAM_CRYPTO_METHOD_SSLv23_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
173174
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT = (1 << 3 | 1),
174175
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT = (1 << 4 | 1),
175176
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT = (1 << 5 | 1),
176-
STREAM_CRYPTO_METHOD_TLS_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
177+
/* tls now equates only to the specific TLSv1 method for BC with pre-5.6 */
178+
STREAM_CRYPTO_METHOD_TLS_CLIENT = (1 << 3 | 1),
179+
STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
177180
STREAM_CRYPTO_METHOD_ANY_CLIENT = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | 1),
178181
STREAM_CRYPTO_METHOD_SSLv2_SERVER = (1 << 1),
179182
STREAM_CRYPTO_METHOD_SSLv3_SERVER = (1 << 2),
180-
STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 1) | (1 << 2)),
183+
/* v23 no longer negotiates SSL2 or SSL3 */
184+
STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)),
181185
STREAM_CRYPTO_METHOD_TLSv1_0_SERVER = (1 << 3),
182186
STREAM_CRYPTO_METHOD_TLSv1_1_SERVER = (1 << 4),
183187
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER = (1 << 5),
184-
STREAM_CRYPTO_METHOD_TLS_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)),
188+
/* tls equates only to the specific TLSv1 method for BC with pre-5.6 */
189+
STREAM_CRYPTO_METHOD_TLS_SERVER = (1 << 3),
190+
STREAM_CRYPTO_METHOD_TLS_ANY_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)),
185191
STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5))
186192
} php_stream_xport_crypt_method_t;
187193

0 commit comments

Comments
 (0)