5.3.0 regression: SSL_set_cert_cb(..., NULL, ...) stores a null function pointer instead of clearing, crashing the next handshake
维护者通常 1 天内回复
评估
调研方向
Start in ssl/ssl_cert.cc at ssl_cert_set_cert_cb (both overloads), where a null callback is stored as an OldCallback instead of resetting to std::monostate, and check CertCb::operator bool() in ssl/internal.h. Then trace do_cert_callback in ssl/handshake_server.cc. A regression test should call SSL_set_cert_cb(ssl, NULL, NULL) and complete a server handshake without invoking a callback. Done when clearing with NULL leaves the callback absent and that test passes, with any boring-sys/patches/ entry kept consistent with the upstream fix.
由索引模型根据 Issue 内容生成。
描述
Summary
In boring / boring-sys 5.3.0 (BoringSSL revision 427ec40c), clearing a certificate callback by passing NULL no longer resets it to the empty state. The null pointer is stored as an OldCallback alternative inside CertCb::cb, so CertCb::operator bool() reports the callback as present, and do_cert_callback then invokes a null function pointer. On our machines this crashes the server process during the resumed TLS handshake and currently keeps us from upgrading to 5.3.0.
Root cause
Introduced by google/boringssl commit 902518a787 ("ssl: Allow certificate selection callback to pick fatal alert"), which turned CERT::cert_cb into struct CertCb { std::variant<std::monostate, OldCallback, NewCallback> }:
// ssl/ssl_cert.cc, ssl_cert_set_cert_cb (both overloads)
- cert->cert_cb = cb;
+ cert->cert_cb.cb = cb;
Assigning a null function pointer selects the OldCallback alternative by exact type match rather than monostate, so the "cleared" representation is no longer reachable through this setter. CertCb::operator bool() (ssl/internal.h) only excludes monostate, and do_cert_callback (ssl/handshake_server.cc) calls the callback whenever that conversion is true.
Reproduction (real world)
Pingora's resumable TLS accept uses exactly this pattern: it arms a blocking cert_cb (suspend_when_need_ssl_cert), pauses the handshake, installs the certificate, then clears the callback with SSL_set_cert_cb(ssl, NULL, NULL) before resuming (unblock_ssl_cert in pingora-boringssl). With 5.3.0 every resumed handshake crashes:
bssl::CertCb::operator()(ssl_st*, void*, unsigned char*) const
bssl::do_cert_callback(bssl::SSL_HANDSHAKE*)
bssl::ssl_server_handshake(bssl::SSL_HANDSHAKE*)
...
SSL_do_handshake
SSL_accept
(excerpt from the macOS crash report: EXC_BAD_ACCESS, invalid address 0x0)
Bisecting boring/boring-sys back to 5.2.0 makes all of this disappear: 33 failing integration tests go back to green. SSL_CTX_set_cert_cb(ctx, NULL, arg) alone should be enough to hit the same path on the next server handshake.
Suggested fix
Normalize a null callback to the empty state in ssl_cert_set_cert_cb, restoring the previous "NULL clears" behavior:
if (cb == nullptr) {
cert->cert_cb.cb = std::monostate();
} else {
cert->cert_cb.cb = cb;
}
(same for the _ex overload.)
Notes
- The same code is present on google/boringssl
mainas of 2026-10-15. - Reproduced on macOS 27.0.1 (26A434) aarch64, rustc 1.99.0; the defect in the C++ itself is platform-independent.
- Happy to send a PR that carries the change as a
boring-sys/patches/entry with a regression test, if that is the preferred route — or to help get it into BoringSSL if you would rather pick it up with the next revision bump.
- 主要语言
- Rust
- 星标
- 526
- 派生
- 178
- 平均合并
- 15 小时 34 分钟
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cloudflare/boring 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
cloudflare/boring#527 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
cloudflare/boring#526 ·
维护者通常 1 天内回复
-
SLH-DSA support可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
cloudflare/boring#522 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
cloudflare/boring#517 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
cloudflare/boring#500 · 2 条评论 ·
维护者通常 1 天内回复
查看 cloudflare/boring 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
adorsys/status-list-server#698 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
nannou-org/egui_graph#92 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 半天 新手友好度 72/100
sujithputta02/Esapay#13 ·
-
Deduplicate normalized_f64_bits (hash_table.rs and bloom_filter.rs)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
tursodatabase/turso#10002 ·
维护者通常 1 天内回复
-
needs triage
难度 2/5 1-3 小时 新手友好度 72/100
topgrade-rs/topgrade#2419 ·
维护者通常 1 天内回复