From 380c3e5127abc3e55d01b89eb92cf6264f85449f Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sun, 24 Apr 2011 23:27:48 +0000 Subject: [PATCH] SSLV2 patch cleanup --- ext/openssl/openssl.c | 4 ++++ ext/openssl/xp_ssl.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 916d322c6a1..e9dd60cae68 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1111,7 +1111,9 @@ PHP_MINIT_FUNCTION(openssl) php_stream_xport_register("ssl", php_openssl_ssl_socket_factory TSRMLS_CC); php_stream_xport_register("sslv3", php_openssl_ssl_socket_factory TSRMLS_CC); +#ifndef OPENSSL_NO_SSL2 php_stream_xport_register("sslv2", php_openssl_ssl_socket_factory TSRMLS_CC); +#endif php_stream_xport_register("tls", php_openssl_ssl_socket_factory TSRMLS_CC); /* override the default tcp socket provider */ @@ -1146,7 +1148,9 @@ PHP_MSHUTDOWN_FUNCTION(openssl) php_unregister_url_stream_wrapper("ftps" TSRMLS_CC); php_stream_xport_unregister("ssl" TSRMLS_CC); +#ifndef OPENSSL_NO_SSL2 php_stream_xport_unregister("sslv2" TSRMLS_CC); +#endif php_stream_xport_unregister("sslv3" TSRMLS_CC); php_stream_xport_unregister("tls" TSRMLS_CC); diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index efff50625f0..f3efe912451 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -330,8 +330,8 @@ static inline int php_openssl_setup_crypto(php_stream *stream, break; case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: #ifdef OPENSSL_NO_SSL2 - php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv2 support is not compiled in openSSL"); - return -1; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv2 support is not compiled into the openSSL library PHP is linked against"); + return -1; #else sslsock->is_client = 1; method = SSLv2_client_method(); @@ -355,8 +355,8 @@ static inline int php_openssl_setup_crypto(php_stream *stream, break; case STREAM_CRYPTO_METHOD_SSLv2_SERVER: #ifdef OPENSSL_NO_SSL2 - php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv2 support is not compiled in openSSL"); - return -1; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv2 support is not compiled into the openSSL library PHP is linked against"); + return -1; #else sslsock->is_client = 0; method = SSLv2_server_method(); @@ -922,8 +922,13 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen, sslsock->enable_on_connect = 1; sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT; } else if (strncmp(proto, "sslv2", protolen) == 0) { +#ifdef OPENSSL_NO_SSL2 + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv2 support is not compiled into the openSSL library PHP is linked against"); + return NULL; +#else sslsock->enable_on_connect = 1; sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT; +#endif } else if (strncmp(proto, "sslv3", protolen) == 0) { sslsock->enable_on_connect = 1; sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT;