Use custom OpenSSL libctx for NCONF (#19130)

This commit is contained in:
Jakub Zelenka 2025-07-15 08:30:15 +01:00 committed by GitHub
parent 142e378618
commit 25c0874bc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View file

@ -297,12 +297,12 @@ int php_openssl_parse_config(struct php_x509_request * req, zval * optional_args
SET_OPTIONAL_STRING_ARG("config", req->config_filename, default_ssl_conf_filename); SET_OPTIONAL_STRING_ARG("config", req->config_filename, default_ssl_conf_filename);
SET_OPTIONAL_STRING_ARG("config_section_name", req->section_name, "req"); SET_OPTIONAL_STRING_ARG("config_section_name", req->section_name, "req");
req->global_config = NCONF_new(NULL); req->global_config = php_openssl_nconf_new();
if (!NCONF_load(req->global_config, default_ssl_conf_filename, NULL)) { if (!NCONF_load(req->global_config, default_ssl_conf_filename, NULL)) {
php_openssl_store_errors(); php_openssl_store_errors();
} }
req->req_config = NCONF_new(NULL); req->req_config = php_openssl_nconf_new();
if (!NCONF_load(req->req_config, req->config_filename, NULL)) { if (!NCONF_load(req->req_config, req->config_filename, NULL)) {
return FAILURE; return FAILURE;
} }

View file

@ -687,4 +687,9 @@ void php_openssl_get_cipher_methods(zval *return_value, bool aliases)
return_value); return_value);
} }
CONF *php_openssl_nconf_new(void)
{
return NCONF_new(NULL);
}
#endif #endif

View file

@ -826,4 +826,9 @@ void php_openssl_get_cipher_methods(zval *return_value, bool aliases)
zend_hash_sort(Z_ARRVAL_P(return_value), php_openssl_compare_func, 1); zend_hash_sort(Z_ARRVAL_P(return_value), php_openssl_compare_func, 1);
} }
CONF *php_openssl_nconf_new(void)
{
return NCONF_new_ex(PHP_OPENSSL_LIBCTX, NULL);
}
#endif #endif

View file

@ -366,4 +366,6 @@ zend_result php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
const EVP_CIPHER *php_openssl_get_evp_cipher_by_name(const char *method); const EVP_CIPHER *php_openssl_get_evp_cipher_by_name(const char *method);
CONF *php_openssl_nconf_new(void);
#endif #endif