Skip to content

Commit e7c84f8

Browse files
committed
Fix issues identified in bukka's review
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
1 parent 74cd9f9 commit e7c84f8

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎ext/openssl/tests/gh25088.phpt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ openssl
55
--SKIPIF--
66
<?php
77
if (!function_exists("proc_open")) die("skip no proc_open");
8-
if (!defined("OPENSSL_VERSION_NUMBER") || OPENSSL_VERSION_NUMBER < 0x10101000) die("skip OpenSSL 1.1.1+ required");
98
?>
109
--FILE--
1110
<?php

‎ext/openssl/xp_ssl.c‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,12 +1486,9 @@ static int php_openssl_server_sni_callback(SSL *ssl_handle, int *al, void *arg)
14861486
}
14871487
/* }}} */
14881488

1489-
/* SSL_set_SSL_CTX() in the SNI callback switches the handshake to the per-host
1490-
* context, so the cipher list, ALPN selection callback, DH parameters and
1491-
* security level are taken from that context instead of the base one. Apply
1492-
* the base context policy to the per-host context. */
1489+
/* Per-host SNI contexts replace the base one, so apply the base policy to them. */
14931490
static zend_result php_openssl_apply_server_policy_to_sni_ctx(php_stream *stream,
1494-
php_openssl_netstream_data_t *sslsock, SSL_CTX *ctx) /* {{{ */
1491+
php_openssl_netstream_data_t *sslsock, SSL_CTX *ctx)
14951492
{
14961493
if (FAILURE == php_openssl_set_cipher_list(stream, ctx)) {
14971494
return FAILURE;
@@ -1513,10 +1510,9 @@ static zend_result php_openssl_apply_server_policy_to_sni_ctx(php_stream *stream
15131510

15141511
return SUCCESS;
15151512
}
1516-
/* }}} */
15171513

15181514
static SSL_CTX *php_openssl_create_sni_server_ctx(php_stream *stream,
1519-
php_openssl_netstream_data_t *sslsock, char *cert_path, char *key_path) /* {{{ */
1515+
php_openssl_netstream_data_t *sslsock, char *cert_path, char *key_path)
15201516
{
15211517
/* The hello method is not inherited by SSL structs when assigning a new context
15221518
* inside the SNI callback, so the just use SSLv23 */
@@ -1526,8 +1522,8 @@ static SSL_CTX *php_openssl_create_sni_server_ctx(php_stream *stream,
15261522
return NULL;
15271523
}
15281524

1529-
/* The security level must be set before loading the certificate and key,
1530-
* as OpenSSL checks them against it. */
1525+
/* Must be done before loading the cert and key, OpenSSL checks them against the
1526+
* security level. */
15311527
if (FAILURE == php_openssl_apply_server_policy_to_sni_ctx(stream, sslsock, ctx)) {
15321528
SSL_CTX_free(ctx);
15331529
return NULL;
@@ -1542,7 +1538,8 @@ static SSL_CTX *php_openssl_create_sni_server_ctx(php_stream *stream,
15421538
);
15431539
SSL_CTX_free(ctx);
15441540
return NULL;
1545-
} else if (SSL_CTX_use_PrivateKey_file(ctx, key_path, SSL_FILETYPE_PEM) != 1) {
1541+
}
1542+
if (SSL_CTX_use_PrivateKey_file(ctx, key_path, SSL_FILETYPE_PEM) != 1) {
15461543
php_error_docref(NULL, E_WARNING,
15471544
"Failed setting private key from file `%s'",
15481545
key_path
@@ -1553,7 +1550,6 @@ static SSL_CTX *php_openssl_create_sni_server_ctx(php_stream *stream,
15531550

15541551
return ctx;
15551552
}
1556-
/* }}} */
15571553

15581554
static zend_result php_openssl_enable_server_sni(
15591555
php_stream *stream, php_openssl_netstream_data_t *sslsock, bool verify_peer)

0 commit comments

Comments
 (0)