Skip to content

Commit bfccc98

Browse files
committed
PHPC-171: SSL Doesn't work in PHP5.6
1 parent 7d19e4f commit bfccc98

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

php_compat_53.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@
3232
} \
3333
}
3434
#endif
35+
36+
/* There was a very bad bug in 5.6.0 through 5.6.6 downgrading
37+
* METHOD_SSLv23 to SSLv2 and SSLv3 exclusively */
38+
#if PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607
39+
# define PHONGO_CRYPTO_METHOD STREAM_CRYPTO_METHOD_ANY_CLIENT
40+
#else
41+
# define PHONGO_CRYPTO_METHOD STREAM_CRYPTO_METHOD_SSLv23_CLIENT
42+
#endif
43+

php_phongo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ mongoc_stream_t* phongo_stream_initiator(const mongoc_uri_t *uri, const mongoc_h
837837
zend_replace_error_handling(EH_THROW, php_phongo_sslconnectionexception_ce, &error_handling TSRMLS_CC);
838838

839839
mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, "Enabling SSL");
840-
if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0) {
840+
if (php_stream_xport_crypto_setup(stream, PHONGO_CRYPTO_METHOD, NULL TSRMLS_CC) < 0) {
841841
zend_restore_error_handling(&error_handling TSRMLS_CC);
842842
php_stream_free(stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
843843
bson_set_error (error, MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_INVALID_TYPE, "Failed to setup crypto, is the OpenSSL extension loaded?");

0 commit comments

Comments
 (0)