php / php/php-src

Have cURL extension look for certificates in directory set by "openssl.capath"

未关闭
#11,944 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Extension: curl Feature Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

I'm on Windows using openssl.cafile and a cacert.pem from curl.se . I also got a local CA certificate that I use. So far I've been just editing any new cacert.pem file to add my certificate. Been working great, but wanted to test if cURL would use openssl.capath to look for it. However, it was just ignoring even with the correct filname (<certificate hash>.0), not even making any access to the directory I set. Only using CURLOPT_CAPATH in the PHP script made it look for the certificate.

Checked out branch "PHP-8.1.22" and looked into ext/curl/interface.c and did the following:

@@ -1817,6 +1817,7 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
 static void _php_curl_set_default_options(php_curl *ch)
 {
 	char *cainfo;
+	char *capath;
 
 	curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS,        1);
 	curl_easy_setopt(ch->cp, CURLOPT_VERBOSE,           0);
@@ -1840,6 +1841,11 @@ static void _php_curl_set_default_options(php_curl *ch)
 	if (cainfo && cainfo[0] != '\0') {
 		curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
 	}
+	
+	capath = INI_STR("openssl.capath");
+	if (capath && capath[0] != '\0') {
+		curl_easy_setopt(ch->cp, CURLOPT_CAPATH, capath);
+	}
 
 #ifdef ZTS
 	curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);

Compiled and tested to be working.

Could also consider adding curl.capath as a setting.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 ext/curl/interface.c 中的 _php_curl_set_default_options 开始,将现有的 openssl.cafile 处理与针对 openssl.capath 的拟议更改进行比较。在 Windows 上使用配置目录中带有哈希的证书构建并测试 cURL 扩展;完成标准是 cURL 使用 openssl.capath,而无需在 PHP 脚本中要求 CURLOPT_CAPATH。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, php
领域
networking, security
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。