Skip to content

Commit 4aac903

Browse files
committed
- [doc] add ini option to set the default cainfo file, in case none was set at compile time
1 parent fee45b7 commit 4aac903

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ext/curl/interface.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,13 @@ zend_module_entry curl_module_entry = {
329329
ZEND_GET_MODULE (curl)
330330
#endif
331331

332+
/* {{{ PHP_INI_BEGIN */
333+
PHP_INI_BEGIN()
334+
PHP_INI_ENTRY("curl.cainfo", "", PHP_INI_SYSTEM, NULL)
335+
PHP_INI_END()
336+
/* }}} */
337+
338+
/* }}} */
332339
/* {{{ PHP_MINFO_FUNCTION
333340
*/
334341
PHP_MINFO_FUNCTION(curl)
@@ -456,6 +463,8 @@ PHP_MINIT_FUNCTION(curl)
456463
le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number);
457464
le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number);
458465

466+
REGISTER_INI_ENTRIES();
467+
459468
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
460469
or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list
461470
of options and which version they were introduced */
@@ -882,6 +891,7 @@ PHP_MSHUTDOWN_FUNCTION(curl)
882891
php_curl_openssl_tsl = NULL;
883892
}
884893
#endif
894+
UNREGISTER_INI_ENTRIES();
885895
return SUCCESS;
886896
}
887897
/* }}} */
@@ -1430,6 +1440,7 @@ PHP_FUNCTION(curl_init)
14301440
zval *clone;
14311441
char *url = NULL;
14321442
int url_len = 0;
1443+
char *cainfo;
14331444

14341445
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &url, &url_len) == FAILURE) {
14351446
return;
@@ -1468,6 +1479,12 @@ PHP_FUNCTION(curl_init)
14681479
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
14691480
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
14701481
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
1482+
1483+
cainfo = INI_STR("curl.cainfo");
1484+
if (cainfo && strlen(cainfo) > 0) {
1485+
curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
1486+
}
1487+
14711488
#if defined(ZTS)
14721489
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
14731490
#endif

0 commit comments

Comments
 (0)