php / php/php-src

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

オープン
#11,944 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Extension: curl Feature Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ext/curl/interface.c の _php_curl_set_default_options から始め、既存の openssl.cafile の処理と、提案されている openssl.capath への変更を比較します。設定されたディレクトリにハッシュ化された証明書を置いて Windows 上で cURL 拡張機能をビルドおよびテストします。cURL が PHP スクリプトで CURLOPT_CAPATH を指定しなくても openssl.capath を使用すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
networking, security
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。