@@ -1448,7 +1448,7 @@ static zend_result php_openssl_enable_server_sni(
14481448 zend_ulong key_index ;
14491449 int i = 0 ;
14501450 char resolved_path_buff [MAXPATHLEN ];
1451- SSL_CTX * ctx ;
1451+ SSL_CTX * ctx = NULL ;
14521452
14531453 /* If the stream ctx disables SNI we're finished here */
14541454 if (GET_VER_OPT ("SNI_enabled" ) && !zend_is_true (val )) {
@@ -1490,6 +1490,8 @@ static zend_result php_openssl_enable_server_sni(
14901490 return FAILURE ;
14911491 }
14921492
1493+ ZVAL_DEREF (current );
1494+
14931495 if (Z_TYPE_P (current ) == IS_ARRAY ) {
14941496 zval * local_pk , * local_cert ;
14951497 zend_string * local_pk_str , * local_cert_str ;
@@ -1544,17 +1546,17 @@ static zend_result php_openssl_enable_server_sni(
15441546 zend_string_release (local_pk_str );
15451547
15461548 ctx = php_openssl_create_sni_server_ctx (resolved_cert_path_buff , resolved_pk_path_buff );
1547-
1548- } else if (php_openssl_check_path_str_ex (
1549- Z_STR_P (current ), resolved_path_buff , 0 , false, false,
1550- "SNI_server_certs in ssl stream context" )) {
1551- ctx = php_openssl_create_sni_server_ctx (resolved_path_buff , resolved_path_buff );
1549+ } else if (Z_TYPE_P (current ) == IS_STRING ) {
1550+ if (php_openssl_check_path_str_ex (Z_STR_P (current ), resolved_path_buff , 0 , false, false, "SNI_server_certs in ssl stream context" )) {
1551+ ctx = php_openssl_create_sni_server_ctx (resolved_path_buff , resolved_path_buff );
1552+ } else {
1553+ php_error_docref (NULL , E_WARNING ,
1554+ "Failed setting local cert chain file `%s'; file not found" ,
1555+ Z_STRVAL_P (current )
1556+ );
1557+ }
15521558 } else {
1553- php_error_docref (NULL , E_WARNING ,
1554- "Failed setting local cert chain file `%s'; file not found" ,
1555- Z_STRVAL_P (current )
1556- );
1557- return FAILURE ;
1559+ php_error_docref (NULL , E_WARNING , "SNI_server_certs options values must be of type array|string" );
15581560 }
15591561
15601562 if (ctx == NULL ) {
0 commit comments