diff options
Diffstat (limited to 'ext/openssl/xp_ssl.c')
| -rw-r--r-- | ext/openssl/xp_ssl.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 7db219ddec..193eb531ee 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -996,6 +996,21 @@ static const SSL_METHOD *php_select_crypto_method(zend_long method_value, int is } /* }}} */ +#define PHP_SSL_MAX_VERSION_LEN 32 + +static char *php_ssl_cipher_get_version(const SSL_CIPHER *c, char *buffer, size_t max_len) /* {{{ */ +{ + const char *version = SSL_CIPHER_get_version(c); + + strncpy(buffer, version, max_len); + if (max_len <= strlen(version)) { + buffer[max_len - 1] = 0; + } + + return buffer; +} +/* }}} */ + static int php_get_crypto_method_ctx_flags(int method_flags) /* {{{ */ { int ssl_ctx_options = SSL_OP_ALL; @@ -1210,7 +1225,7 @@ static int set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /* {{{ */ /* }}} */ #endif -#ifdef HAVE_ECDH +#if defined(HAVE_ECDH) && (OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)) static int set_server_ecdh_curve(php_stream *stream, SSL_CTX *ctx) /* {{{ */ { zval *zvcurve; @@ -1253,7 +1268,7 @@ static int set_server_specific_opts(php_stream *stream, SSL_CTX *ctx) /* {{{ */ zval *zv; long ssl_ctx_options = SSL_CTX_get_options(ctx); -#ifdef HAVE_ECDH +#if defined(HAVE_ECDH) && (OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)) if (set_server_ecdh_curve(stream, ctx) == FAILURE) { return FAILURE; } @@ -1684,6 +1699,7 @@ static zend_array *capture_session_meta(SSL *ssl_handle) /* {{{ */ char *proto_str; long proto = SSL_version(ssl_handle); const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl_handle); + char version_str[PHP_SSL_MAX_VERSION_LEN]; switch (proto) { #ifdef HAVE_TLS12 @@ -1716,7 +1732,7 @@ static zend_array *capture_session_meta(SSL *ssl_handle) /* {{{ */ add_assoc_string(&meta_arr, "protocol", proto_str); add_assoc_string(&meta_arr, "cipher_name", (char *) SSL_CIPHER_get_name(cipher)); add_assoc_long(&meta_arr, "cipher_bits", SSL_CIPHER_get_bits(cipher, NULL)); - add_assoc_string(&meta_arr, "cipher_version", SSL_CIPHER_get_version(cipher)); + add_assoc_string(&meta_arr, "cipher_version", php_ssl_cipher_get_version(cipher, version_str, PHP_SSL_MAX_VERSION_LEN)); return Z_ARR(meta_arr); } @@ -2292,6 +2308,7 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val if (sslsock->ssl_active) { zval tmp; char *proto_str; + char version_str[PHP_SSL_MAX_VERSION_LEN]; const SSL_CIPHER *cipher; array_init(&tmp); @@ -2318,7 +2335,7 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val add_assoc_string(&tmp, "protocol", proto_str); add_assoc_string(&tmp, "cipher_name", (char *) SSL_CIPHER_get_name(cipher)); add_assoc_long(&tmp, "cipher_bits", SSL_CIPHER_get_bits(cipher, NULL)); - add_assoc_string(&tmp, "cipher_version", SSL_CIPHER_get_version(cipher)); + add_assoc_string(&tmp, "cipher_version", php_ssl_cipher_get_version(cipher, version_str, PHP_SSL_MAX_VERSION_LEN)); #ifdef HAVE_TLS_ALPN { |
