check_cert() and php_openssl_store_errors do not pick up validation errors
未关闭
还没有人认领这个 Issue。
Extension: openssl
Feature
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 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 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 ext/openssl 中 check_cert() 和 php_openssl_store_errors() 附近的内部实现开始,然后跟踪 issue 中描述的 X509_verify_cert() 错误路径。使用 a.pem 运行提供的 PHP 复现程序;当验证错误通过 openssl_error_string() 与 false 结果一同暴露时,工作就完成了。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- security
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100