ext-mysqlnd: can't set SSL server hostname verification independent of general certificate validation
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 103
描述
Description
The mysql command line client and related tools verify SSL certificates, but by default do not verify that the server name used to connect matches the Subject CN, or one of the SAN extension entries, of the server certificate.
This additional verification needs to be requested using the --ssl-verify-server-cert option (which was not the best name for this, -ssl-verify-server-cert-hostname would have been a better choice, bu that is a different story); or when using encrypted replication: the MASTER_SSL_VERIFY_SERVER_CERT=1 option to CHANGE MASTER.
With mysqlnd though both verification aspects are tightly coupled, and can only be both on, or both off, controlled by the single MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag.
See also: ext/mysqlnd/mysqlnd_vio.c:
555 ZVAL_BOOL(&verify_peer_zval, verify);
556 php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval);
557 php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval);
https://github.com/php/php-src/blob/master/ext/mysqlnd/mysqlnd_vio.c#L555
There needs to be an extra option like MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_HOSTNAME to control hostname verification independent of general certificate verification.
PHP Version
PHP 8.1.2
Operating System
Ubuntu 22.04
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
阅读 ext/mysqlnd/mysqlnd_vio.c 第 555–557 行附近的内容,这里 verify_peer 和 verify_peer_name 被同时设置,并检查 MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT 标志。当可以通过额外的选项独立控制主机名验证,同时仍可单独控制常规证书验证时,此更改即告完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, mysql
- 领域
- databases, security
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100