-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Cert Pinning #8234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cert Pinning #8234
Conversation
|
UI 好像不太好看,后面看下怎么改进吧 |
|
内置一份 CA 指纹 Pinning,避免用户电脑已经被置入恶意 CA 获取到错误证书 |
|
脚本如下 import requests
import re
# Trusted CA Cert URL
url = "https://hg-edge.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt"
# Get Fingerprints (SHA-256) from certdata.txt
# Fingerprint (SHA-256): EB:D4:10:40:... CKA_CLASS CK_OBJECT_CLASS ... CKA_LABEL UTF8 "GlobalSign Root CA"
# Returns a string of fingerprints:
# "EBD41040...", // GlobalSign Root CA
# ...
def get_fingerprints(url):
response = requests.get(url)
data = response.text
# Regex to find SHA-256 fingerprints and their labels
pattern = r'Fingerprint \(SHA-256\): ([A-F0-9:]+).*?CKA_LABEL UTF8 "([^"]+)"'
matches = re.findall(pattern, data, re.DOTALL)
# Remove duplicates while preserving first-seen order.
fingerprints = []
seen = set()
for match in matches:
# normalize fingerprint: remove colons and uppercase
fingerprint = match[0].replace(":", "").upper()
label = match[1].strip()
if fingerprint in seen:
continue
seen.add(fingerprint)
fingerprints.append(f'"{fingerprint}", // {label}')
return fingerprints
if __name__ == "__main__":
fingerprints = get_fingerprints(url)
for fp in fingerprints:
print(fp) |
|
感谢你的 PR。 |
|
因为用户友好啊,并且 C# 有现成的类和方法 "" | openssl s_client -servername example.com -connect example.com:443 2>$null | openssl x509比起这种方法更方便 一是不需要安装 openssl,二是可以验证 CA 证书是否可信 |
|
rebase? |
| { | ||
| domain += $":{SelectedSource.Port}"; | ||
| } | ||
| Cert = await CertPemManager.Instance.GetCertPemAsync(domain, serverName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个获取的时候,把异常结果返回并显示出来吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
但是大部分情况是 AddServerWindow 直接把 MainWindow 的 StatusBarView 挡住的,用户根本看不到
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以用 TextBlock 文本控件在当前页面,比如原来已有的说明的地方,直接替换为异常信息
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啊,才发现,原来是 753e7b8 这意思,我还以为说的是前面的直接 return 需要做提示
我还在想为什么在这 Comment,语文没学好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
做个国际化是不是更好?比如证书验证失败和该CA不受信任,能区分是自签还是恶意 CA ,感觉用户友好一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以加你说的更友好的提示。
但是有时候域名会连接都不成功,这部分还是要提示出来
|
填写证书后,底层自动禁用 AllowInsecure 吧 一是符合目前界面说明的逻辑,二是避免用户填写了,但是 AllowInsecure = true 导致实际未使用的情况 |
|
不过现有的大多数客户端,固定证书和 AllowInsecure 是独立的 |
所以做吗?目前是即使填了证书,AllowInsecure 还是不会去验证 |
做呗,你可以继续完善功能。 |
|
不是完善,是这个逻辑和现有的大部分客户端冲突 |
|
但是这个逻辑我认为是合理的,填写了证书应该禁用 AllowInsecure |
|
所以问问你的意见 |
比如 nekobox, Exclave, husi 这些 |
挺合理的 |
|
两位大佬好,十分期望证书指纹能实现啊,无论使用 sha256(clash和小火箭的格式) 还是 base64 (sing-box的格式)都可以。 因为我是使用 sing-box 服务端,使用自签的,现在 v2rayN 在 trojan / hysteria2 / tuic / anyTLS 等,都要在 TLS 处 AllowInsecure = true。为了添加安全性,希望用证书指纹替代。现在小火箭 / clash mihomo / sing-box 客户端都可以实现了。但我还是喜欢用 v2rayN,感谢了! |
#7977 ,xray 和 sing-box 无法同时适配 xray 是打算 公钥哈希 -> 密钥指纹
|
|
这两天需要发一个版本,此 pr 已经合并,发出来用用先吧,属于实验性功能。 |
协议URI要支持证书指纹的参数啊,否则不利于节点的导入、导出和订阅。 |
你举得这两例子不合适。小火箭因为 iphone 的原因;clash 根本不需要管参数,因为它的参数自己决定的。 这边为什么坚持用 XTLS/Xray-core#716 这个规范,是因为这个规范制定的算比较合理的,我们应该尽量尊重和推广,这样才会更方便开发和使用。 如果上面提到的规范里面没有,建议先给这个规范反馈和提交我们的建议,这样更好。 VLESS allowInsecure 事实上也已经加进去了。 |
tuic 的 allowInsecure 应该没有吧? |
|
我举那个例子,的确是我现在的使用情况,现在大家都不是一个客户端的了,pc有windows / mac ,手机有 安卓和 苹果,同一个节点,都是混着来的。其他工具分享无阻碍,就显得v2rayN在这方面保守了。 |
|
|
|
@fscarmen 新开一个 issue,把需要分享和解析的这个部分都发出来吧,我们一次都给加上。 |
|
|
其实老早就有想过。 |






固定证书
部分机场节点和 OpenSSL 获取到的 TLS 证书不一致,虽然 Wireshark 抓包显示 SNI 和目标地址一致,原因未知