我应该采取哪些步骤来像浏览器一样手动验证 SSL 证书?

What steps should I take to validate a SSL Certificate manually as browsers do?

像Chrome这样的浏览器如何检查SSL证书?

是否有他们使用的在线数据库或网站?

浏览器采用哪些步骤来验证 SSL 证书?

我可以不使用浏览器手动完成吗?

How do browsers like Chrome check SSL Certificate?

证书和链在 SSL 握手期间由服务器发送。浏览器将根据证书颁发者、提供的链证书和本地根证书创建信任链。它将检查证书的有效期和用途,并检查主题备用名称(也可能是主题)以确保证书实际上是为 URL 中的域颁发的。它还可能对证书吊销进行一些检查。

详情见SSL Certificate framework 101: How does the browser actually verify the validity of a given server certificate? and How Do Browsers Handle Revoked SSL/TLS Certificates?

I there any online database or websites that they use?

不是真的。必要的信任库是本地的。他们可能会根据某些在线资源检查撤销。参见 Is Certificate validation done completely local?

Am I able to do it manually without using browser?

当然,理论上可以手动复制浏览器的功能。例如,您可以访问该站点并使用 openssl s_client -showcerts ... 获取叶证书和中间证书。然后您可以使用 openssl verify 来验证证书链,另请参阅 Verify a certificate chain using openssl verify. Then you need to look at the leaf certificate with openssl x509 -text ... to check purpose, expiration and the subject. Revocation is tricky but could be done with the help of openssl crl and openssl ocsp, although this does not really reflect what browsers do.

验证任何 SSL/TLS 证书的官方算法是 defined by PKIX as modified by OCSP. For TLS nowadays the OCSP token is often transported by 'stapling' in the TLS handshake instead of by a separate connection, which requires several other RFCs, but that only affects transport, not the actual validation by the relier. For HTTPS specifically, the client must also check server identity aka 'hostname' as defined by rfc2818

实际上,浏览器可能会有所不同。 Chrome 主要使用 google-determined 方案来 'push' 撤销他们 select 的数据,但这会不时发生变化。 Firefox,我最后听说,使用他们自己的 'one-CRL' 方案。此外,尽管标准和传统做法是根据 SAN 检查主机名(如果存在),否则回退到 Subject.CN、Chrome,因为几年前 需要 SAN 和从不使用 CN;你可以在几个堆栈上找到几十个关于“我的自签名或其他 DIY 证书不是来自真正的 CA 停止在 Chrome 上工作”的问题。

如果 'do it manually' 你的意思是手动,那将是一项 很多 的工作。如果您的意思是使用离线浏览器以外的工具,则更容易一些; OpenSSL(如果已安装)可以完成 大部分,尽管您需要比 Steffen link 中显示的选项更多的选项才能正确使用。

如果您的意思是使用浏览器以外的工具在线,绝对可以。 WWW 在最近几十年变得非常流行,有无数的程序和库可以访问它,几乎所有的程序和库都包括 HTTPS(尽管二十年前还不太常见),其中包括验证证书——至少在默认情况下是这样;许多都有禁用、绕过或覆盖验证的选项。有独立的工具,如 curlwget —— 或 openssl s_client 可以完成 SSL/TLS 和证书部分,而无需在顶部执行 HTTP。有无数的库和中间件,例如 python 中的 ssl(或使用它的 requests),nodejs 中的 tls,(较旧的)HttpsURLConnection 和(较新的)java.net.http 在 Java 以及 third-parties 像 Apache HttpComponents;我确信 perl 和 dotnet 有对应的版本,尽管我不熟悉它们。还有powershell,在program/library区分上比较模糊