@@ -499,8 +499,8 @@ int php_openssl_get_ssl_stream_data_index(void)
499
499
static char default_ssl_conf_filename [MAXPATHLEN ];
500
500
501
501
struct php_x509_request { /* {{{ */
502
- LHASH_OF ( CONF_VALUE ) * global_config ; /* Global SSL config */
503
- LHASH_OF ( CONF_VALUE ) * req_config ; /* SSL config for this request */
502
+ CONF * global_config ; /* Global SSL config */
503
+ CONF * req_config ; /* SSL config for this request */
504
504
const EVP_MD * md_alg ;
505
505
const EVP_MD * digest ;
506
506
char * section_name ,
@@ -711,13 +711,13 @@ static time_t php_openssl_asn1_time_to_time_t(ASN1_UTCTIME * timestr) /* {{{ */
711
711
}
712
712
/* }}} */
713
713
714
- static inline int php_openssl_config_check_syntax (const char * section_label , const char * config_filename , const char * section , LHASH_OF ( CONF_VALUE ) * config ) /* {{{ */
714
+ static inline int php_openssl_config_check_syntax (const char * section_label , const char * config_filename , const char * section , CONF * config ) /* {{{ */
715
715
{
716
716
X509V3_CTX ctx ;
717
717
718
718
X509V3_set_ctx_test (& ctx );
719
- X509V3_set_conf_lhash (& ctx , config );
720
- if (!X509V3_EXT_add_conf (config , & ctx , (char * )section , NULL )) {
719
+ X509V3_set_nconf (& ctx , config );
720
+ if (!X509V3_EXT_add_nconf (config , & ctx , (char * )section , NULL )) {
721
721
php_openssl_store_errors ();
722
722
php_error_docref (NULL , E_WARNING , "Error loading %s section %s of %s" ,
723
723
section_label ,
@@ -729,17 +729,24 @@ static inline int php_openssl_config_check_syntax(const char * section_label, co
729
729
}
730
730
/* }}} */
731
731
732
- static char * php_openssl_conf_get_string (
733
- LHASH_OF (CONF_VALUE ) * conf , const char * group , const char * name ) {
734
- char * str = CONF_get_string (conf , group , name );
735
- if (str == NULL ) {
736
- /* OpenSSL reports an error if a configuration value is not found.
737
- * However, we don't want to generate errors for optional configuration. */
738
- ERR_clear_error ();
739
- }
732
+ static char * php_openssl_conf_get_string (CONF * conf , const char * group , const char * name ) {
733
+ /* OpenSSL reports an error if a configuration value is not found.
734
+ * However, we don't want to generate errors for optional configuration. */
735
+ ERR_set_mark ();
736
+ char * str = NCONF_get_string (conf , group , name );
737
+ ERR_pop_to_mark ();
740
738
return str ;
741
739
}
742
740
741
+ static long php_openssl_conf_get_number (CONF * conf , const char * group , const char * name ) {
742
+ /* Same here, ignore errors. */
743
+ long res = 0 ;
744
+ ERR_set_mark ();
745
+ NCONF_get_number (conf , group , name , & res );
746
+ ERR_pop_to_mark ();
747
+ return res ;
748
+ }
749
+
743
750
static int php_openssl_add_oid_section (struct php_x509_request * req ) /* {{{ */
744
751
{
745
752
char * str ;
@@ -751,7 +758,7 @@ static int php_openssl_add_oid_section(struct php_x509_request * req) /* {{{ */
751
758
if (str == NULL ) {
752
759
return SUCCESS ;
753
760
}
754
- sktmp = CONF_get_section (req -> req_config , str );
761
+ sktmp = NCONF_get_section (req -> req_config , str );
755
762
if (sktmp == NULL ) {
756
763
php_openssl_store_errors ();
757
764
php_error_docref (NULL , E_WARNING , "Problem loading oid section %s" , str );
@@ -822,13 +829,13 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
822
829
823
830
SET_OPTIONAL_STRING_ARG ("config" , req -> config_filename , default_ssl_conf_filename );
824
831
SET_OPTIONAL_STRING_ARG ("config_section_name" , req -> section_name , "req" );
825
- req -> global_config = CONF_load ( NULL , default_ssl_conf_filename , NULL );
826
- if (req -> global_config == NULL ) {
832
+ req -> global_config = NCONF_new ( NULL );
833
+ if (! NCONF_load ( req -> global_config , default_ssl_conf_filename , NULL ) ) {
827
834
php_openssl_store_errors ();
828
835
}
829
- req -> req_config = CONF_load ( NULL , req -> config_filename , NULL );
830
- if ( req -> req_config == NULL ) {
831
- php_openssl_store_errors ();
836
+
837
+ req -> req_config = NCONF_new ( NULL );
838
+ if (! NCONF_load ( req -> req_config , req -> config_filename , NULL )) {
832
839
return FAILURE ;
833
840
}
834
841
@@ -852,8 +859,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
852
859
SET_OPTIONAL_STRING_ARG ("req_extensions" , req -> request_extensions_section ,
853
860
php_openssl_conf_get_string (req -> req_config , req -> section_name , "req_extensions" ));
854
861
SET_OPTIONAL_LONG_ARG ("private_key_bits" , req -> priv_key_bits ,
855
- CONF_get_number (req -> req_config , req -> section_name , "default_bits" ));
856
-
862
+ php_openssl_conf_get_number (req -> req_config , req -> section_name , "default_bits" ));
857
863
SET_OPTIONAL_LONG_ARG ("private_key_type" , req -> priv_key_type , OPENSSL_KEYTYPE_DEFAULT );
858
864
859
865
if (optional_args && (item = zend_hash_str_find (Z_ARRVAL_P (optional_args ), "encrypt_key" , sizeof ("encrypt_key" )- 1 )) != NULL ) {
@@ -933,11 +939,11 @@ static void php_openssl_dispose_config(struct php_x509_request * req) /* {{{ */
933
939
req -> priv_key = NULL ;
934
940
}
935
941
if (req -> global_config ) {
936
- CONF_free (req -> global_config );
942
+ NCONF_free (req -> global_config );
937
943
req -> global_config = NULL ;
938
944
}
939
945
if (req -> req_config ) {
940
- CONF_free (req -> req_config );
946
+ NCONF_free (req -> req_config );
941
947
req -> req_config = NULL ;
942
948
}
943
949
}
@@ -2821,12 +2827,12 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z
2821
2827
STACK_OF (CONF_VALUE ) * dn_sk , * attr_sk = NULL ;
2822
2828
char * str , * dn_sect , * attr_sect ;
2823
2829
2824
- dn_sect = CONF_get_string (req -> req_config , req -> section_name , "distinguished_name" );
2830
+ dn_sect = NCONF_get_string (req -> req_config , req -> section_name , "distinguished_name" );
2825
2831
if (dn_sect == NULL ) {
2826
2832
php_openssl_store_errors ();
2827
2833
return FAILURE ;
2828
2834
}
2829
- dn_sk = CONF_get_section (req -> req_config , dn_sect );
2835
+ dn_sk = NCONF_get_section (req -> req_config , dn_sect );
2830
2836
if (dn_sk == NULL ) {
2831
2837
php_openssl_store_errors ();
2832
2838
return FAILURE ;
@@ -2835,7 +2841,7 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z
2835
2841
if (attr_sect == NULL ) {
2836
2842
attr_sk = NULL ;
2837
2843
} else {
2838
- attr_sk = CONF_get_section (req -> req_config , attr_sect );
2844
+ attr_sk = NCONF_get_section (req -> req_config , attr_sect );
2839
2845
if (attr_sk == NULL ) {
2840
2846
php_openssl_store_errors ();
2841
2847
return FAILURE ;
@@ -3252,8 +3258,8 @@ PHP_FUNCTION(openssl_csr_sign)
3252
3258
X509V3_CTX ctx ;
3253
3259
3254
3260
X509V3_set_ctx (& ctx , cert , new_cert , csr , NULL , 0 );
3255
- X509V3_set_conf_lhash (& ctx , req .req_config );
3256
- if (!X509V3_EXT_add_conf (req .req_config , & ctx , req .extensions_section , new_cert )) {
3261
+ X509V3_set_nconf (& ctx , req .req_config );
3262
+ if (!X509V3_EXT_add_nconf (req .req_config , & ctx , req .extensions_section , new_cert )) {
3257
3263
php_openssl_store_errors ();
3258
3264
goto cleanup ;
3259
3265
}
@@ -3326,10 +3332,10 @@ PHP_FUNCTION(openssl_csr_new)
3326
3332
X509V3_CTX ext_ctx ;
3327
3333
3328
3334
X509V3_set_ctx (& ext_ctx , NULL , NULL , csr , NULL , 0 );
3329
- X509V3_set_conf_lhash (& ext_ctx , req .req_config );
3335
+ X509V3_set_nconf (& ext_ctx , req .req_config );
3330
3336
3331
3337
/* Add extensions */
3332
- if (req .request_extensions_section && !X509V3_EXT_REQ_add_conf (req .req_config ,
3338
+ if (req .request_extensions_section && !X509V3_EXT_REQ_add_nconf (req .req_config ,
3333
3339
& ext_ctx , req .request_extensions_section , csr ))
3334
3340
{
3335
3341
php_openssl_store_errors ();
0 commit comments