@@ -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. */
14931490static 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
15181514static 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
15581554static zend_result php_openssl_enable_server_sni (
15591555 php_stream * stream , php_openssl_netstream_data_t * sslsock , bool verify_peer )
0 commit comments