fix(proxy): leaf cert AKI must equal CA SKI; cap validity at 398 days (CA/B BR 2020-09)#92
Open
YiShan-X wants to merge 1 commit into
Open
fix(proxy): leaf cert AKI must equal CA SKI; cap validity at 398 days (CA/B BR 2020-09)#92YiShan-X wants to merge 1 commit into
YiShan-X wants to merge 1 commit into
Conversation
Two independent bugs in CaManager.issueLeafCert were causing MITM leaf certs to be rejected by Android Chrome and strict CertPathValidator clients: 1. authorityKeyIdentifier.keyIdentifier was set to true, causing node-forge to compute the AKI from the LEAF's own public key. Per RFC 5280 §4.2.1.1 the AKI must equal the issuer's SKI; with the buggy code each hostname got a random AKI value, breaking the trust-anchor lookup in CertPathValidator / OkHttp / JSSE. 2. LEAF_VALIDITY_DAYS was 825 (Apple's pre-2020 max). Since 2020-09-01 the CA/Browser Forum caps all leaf certs at 398 days; Chrome / Firefox / iOS 15+ / Android Chrome enforce it strictly and reject longer certs with ERR_CERT_VALIDITY_TOO_LONG. Fix: - Use this.caCert.generateSubjectKeyIdentifier().getBytes() for the AKI. - Lower LEAF_VALIDITY_DAYS to 365 (safely below 398 for all modern browsers AND below the legacy 825 cap for iOS <=14 / older macOS, so Apple platforms are unaffected). Also adds verify-aki-fix.cjs: a reproducible verification script that generates a CA + two leaf certs via node-forge and prints AKI/SKI/ dates so a reviewer can confirm the fix end-to-end. Verified locally on Windows / Electron 35.7.5: openssl verify -purpose sslserver passes, AKI equals CA SKI for every leaf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修复 MITM 代理签发叶子证书时的两个独立 bug:
authorityKeyIdentifier用了keyIdentifier: true,node-forge 会拿叶子自己的公钥算 SHA-1 填进 AKI,每个域名都得到一个不同的"随机值"。RFC 5280 §4.2.1.1 规定 AKI 必须等于签发者的 SKI,否则 AndroidCertPathValidator、OkHttp、JSSE 等严格路径直接抛TrustAnchor not found。LEAF_VALIDITY_DAYS = 825是 2017-2020 间 Apple 的旧上限。CA/Browser Forum 自 2020-09-01 起把全行业叶子证书上限统一压到 398 天,Chrome / Firefox / iOS 15+ / Android Chrome 均按 398 天强校验,过长会直接返回NET::ERR_CERT_VALIDITY_TOO_LONG。兼容性
LEAF_VALIDITY_DAYS取 365,对所有 Apple 平台安全:AKI改动只影响 ASN.1 结构语义,对所有 RFC 5280 实现的客户端都更正确,没有兼容性回归。Reproduction (before fix)
同一张 CA(SKI =
C7:75:A9:B7:F6:05:3C:C0:B6:16:3E:FF:9C:35:5C:3E:73:40:5D:BF)下:92:05:7F…(≠ CA SKI)B7:C1:64…(≠ CA SKI)C7:75:A9:B7…(= CA SKI)C7:75:A9:B7…(= CA SKI)Verification
端到端复现脚本(可放
tools/):CA + 两个域名叶子证书,用 openssl dump AKI/SKI/dates 并做openssl verify。Diff
Related
ERR_CERT_COMMON_NAME_INVALID是 SAN 扩展缺失,需另开 PRChecklist
openssl verify -purpose sslserver严格校验contextCache在进程重启后清空,无兼容性回归