check_cert() and php_openssl_store_errors do not pick up validation errors
オープン
まだ誰も着手していません。
Extension: openssl
Feature
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
var_dump(openssl_x509_checkpurpose(file_get_contents('a.pem'), X509_PURPOSE_SSL_SERVER));
while ($msg = openssl_error_string())
echo $msg . "<br />\n";"
where a.pem is
wget https://raw.githubusercontent.com/fuzyll/defcon-vm/master/extras/hfd/server.pem -O a.pem
(or any other single certificate file that won't validate; without intermediates etc)
Resulted in this output:
$ php x.php
bool(false)
But I expected this output instead:
$ php x.php
bool(false)
error: certificate chain too long (depth 0)
(or similar error message).
Why this doesn't work currently? Because X509_verify_cert() in check_cert() validation errors need to be picked up by
error = X509_STORE_CTX_get_error(csc)
X509_verify_cert_error_string(error)
X509_STORE_CTX_get_error_depth(csc)
which is not done in php ext/openssl internals.
PHP Version
PHP 8.1.4
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
check_cert() と php_openssl_store_errors() 周辺の ext/openssl の内部から始め、issue で説明されている X509_verify_cert() のエラーパスを追跡します。提供された PHP の再現コードを a.pem とともに実行します。openssl_error_string() を通じて、false の結果と併せて検証エラーが公開されれば作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- security
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100