Have cURL extension look for certificates in directory set by "openssl.capath"
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong ext/curl/interface.c tại _php_curl_set_default_options và so sánh cách xử lý openssl.cafile hiện có với thay đổi được đề xuất cho openssl.capath. Build và kiểm thử extension cURL trên Windows với một chứng chỉ được băm trong thư mục đã cấu hình; hoàn thành khi cURL sử dụng openssl.capath mà không yêu cầu CURLOPT_CAPATH trong script PHP.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php
- Lĩnh vực
- networking, security
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100