From 714eb8069ac2f33a6a886d35da16176c2dd2a4ad Mon Sep 17 00:00:00 2001 From: Stefan Esser Date: Thu, 12 Sep 2002 21:52:09 +0000 Subject: [PATCH] made new ssl activate function the default. --- ext/standard/fsock.c | 4 ++-- ext/standard/ftp_fopen_wrapper.c | 4 ++-- main/network.c | 13 +++++++++---- main/php_network.h | 5 ++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c index ec181f125ea..09315fa5755 100644 --- a/ext/standard/fsock.c +++ b/ext/standard/fsock.c @@ -227,10 +227,10 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent) int ssl_ret = FAILURE; switch(ssl_flags) { case php_ssl_v23: - ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, SSLv23_client_method() TSRMLS_CC); + ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, SSLv23_client_method(), NULL TSRMLS_CC); break; case php_ssl_tls: - ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, TLSv1_client_method() TSRMLS_CC); + ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, TLSv1_client_method(), NULL TSRMLS_CC); break; default: /* unknown ?? */ diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 29ed63b84a6..c5f2503542d 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -204,7 +204,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch } if (use_ssl) { - if (use_ssl && php_stream_sock_ssl_activate_with_method(stream, 1, SSLv23_method()) == FAILURE) { + if (use_ssl && php_stream_sock_ssl_activate(stream, 1) == FAILURE) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to activate SSL mode"); php_stream_close(stream); stream = NULL; @@ -415,7 +415,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch php_stream_notify_progress_init(context, 0, file_size); #if HAVE_OPENSSL_EXT - if (use_ssl_on_data && php_stream_sock_ssl_activate_with_method_ex(datastream, 1, SSLv23_method(), reuseid) == FAILURE) { + if (use_ssl_on_data && php_stream_sock_ssl_activate_with_method(datastream, 1, SSLv23_method(), reuseid) == FAILURE) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to activate SSL mode"); php_stream_close(datastream); datastream = NULL; diff --git a/main/network.c b/main/network.c index e175b0808eb..22d7a2a95a3 100644 --- a/main/network.c +++ b/main/network.c @@ -602,20 +602,25 @@ PHPAPI php_stream *_php_stream_sock_open_unix(const char *path, int pathlen, int } #if HAVE_OPENSSL_EXT -PHPAPI int php_stream_sock_ssl_activate_with_method_ex(php_stream *stream, int activate, SSL_METHOD *method, php_stream *control TSRMLS_DC) +PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int activate, SSL_METHOD *method, php_stream *session_stream TSRMLS_DC) { php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; php_netstream_data_t *psock = NULL; SSL_CTX *ctx = NULL; - if (control) { - psock = (php_netstream_data_t*)control->abstract; - } if (!php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_stream_sock_ssl_activate_with_method: stream is not a network stream"); return FAILURE; } + + if (session_stream) { + if (!php_stream_is(session_stream, PHP_STREAM_IS_SOCKET)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_stream_sock_ssl_activate_with_method: session_stream is not a network stream"); + return FAILURE; + } + psock = (php_netstream_data_t*)session_stream->abstract; + } if (activate == sock->ssl_active) return SUCCESS; /* already in desired mode */ diff --git a/main/php_network.h b/main/php_network.h index 139f19ce8fa..52793779866 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -148,9 +148,8 @@ PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *time PHPAPI size_t php_stream_sock_set_chunk_size(php_stream *stream, size_t size TSRMLS_DC); #if HAVE_OPENSSL_EXT -PHPAPI int php_stream_sock_ssl_activate_with_method_ex(php_stream *stream, int activate, SSL_METHOD *method, php_stream *control TSRMLS_DC); -#define php_stream_sock_ssl_activate_with_method(stream, activate, method) php_stream_sock_ssl_activate_with_method_ex((stream), (activate), SSLv23_client_method(), NULL TSRMLS_CC) -#define php_stream_sock_ssl_activate(stream, activate) php_stream_sock_ssl_activate_with_method((stream), (activate), SSLv23_client_method() TSRMLS_CC) +PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int activate, SSL_METHOD *method, php_stream *session_stream TSRMLS_DC); +#define php_stream_sock_ssl_activate(stream, activate) php_stream_sock_ssl_activate_with_method((stream), (activate), SSLv23_client_method(), NULL TSRMLS_CC) #endif