版本
Ubuntu 20.04,OpenSSL 1.1.1f
我的 Openssl 应该具有默认启用受信任优先选项的功能(或者如果您愿意,也可以称为“错误修复”)。并且这一点已得到确认:
17:57UTC:root@bard:/etc# openssl verify -help 2>&1| grep trusted_first
-trusted_first search trust store first (default)
证书和证书链(见下文)在网络服务器中安装后运行良好。此证书已安装,本地curl
命令行和我的网络浏览器均对证书和证书链文件(见下文)感到满意。
我在这里试图解决的问题是,我无法核实此链和证书文件使用 openssl 从命令行。
ISRG Root X1 安装了吗?
是的。已安装,并且 ca-certificates 正常。
17:57UTC:root@bard:/etc# ls /usr/share/ca-certificates/mozilla/ISRG_Root_X1.crt
-rw-r--r-- 1 root root 1939 Sep 22 11:46 /usr/share/ca-certificates/mozilla/ISRG_Root_X1.crt
17:59UTC:root@bard:/etc# grep ISRG /etc/ca-certificates.conf
mozilla/ISRG_Root_X1.crt
17:59UTC:root@bard:/etc# update-ca-certificates
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
证书和证书链
Cert 是一个文件,并且有一个包含两个证书的证书链文件。
这是证书……
-----BEGIN CERTIFICATE-----
MIIFKDCCBBCgAwIBAgISA1G6nqla/B5CEPZI6YO4Y7eIMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yMTA5MTcwNjE1MjBaFw0yMTEyMTYwNjE1MTlaMBwxGjAYBgNVBAMT
EXdpbmRzb3IuYmxrYnguY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEA2vM7VD207G7s04jA5QSG9jmmYCO+xi+4B/nnID66BIA5YJ05ZU6iahuIWDHn
hqfHNW/E+DlouC6MqInuAPOuOMhkQ8sOJMXOwvMXwKbuH5TmkBzieMHcp1X2igAm
/3tGFXzJ4kCLvmm3OOttwAC+fS38F7+pLKQ/yEnNtV/nZbYlHWAJj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OqRF3xAK/TYbIFpLjsBfetDoE+Tz2Vqa7sAYwH4J5IIVXt4LQef
PoHapxOmUO4+gfDqkVwKlXYXyKTCoIH0JUEfuwuA4hABBnbD6WDh0Zt4RO+ZYd9C
8Lh14YixuupKu3/Xm+yjT7OksVU9zX65gJ9Pades/qjHMb58SCli5ouljueLLNrJ
9/jhxM/5bcom4AgMvIybU2UnXaTDKkw5PhYRE9d6O8hSy1AZ4txKDyYEy9rESeR0
cDn5dB90nx74SJXHQfK2ScC2oVNvz4MXAPrYEg==
-----END CERTIFICATE-----
该链文件有两个中间证书。第一个(“MIIFFj…”)由较新的“ISRG Root X1”CA 证书签名,第二个(“MIIFYD…”)由旧的/现已过期的“DST whateveritwas X3”签名。
这是链文件……
-----BEGIN CERTIFICATE-----
MIIFFjCCAv6gAwIBAgIRAJErCErPDBinU/bWLiWnX1owDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjAwOTA0MDAwMDAw
WhcNMjUwOTE1MTYwMDAwWjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg
RW5jcnlwdDELMAkGA1UEAxMCUjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQC7AhUozPaglNMPEuyNVZLD+ILxmaZ6QoinXSaqtSu5xUyxr45r+XXIo9cP
R5QUVTVXjJ6oojkZ9YI8QqlObvU7wy7bjcCwXPNZOOftz2nwWgsbvsCUJCWH+jdx
sxPnHKzhm+/b5DtFUkWWqcFTzjTIUu61ru2P3mBw4qVUq7ZtDpelQDRrK9O8Zutm
NHz6a4uPVymZ+DAXXbpyb/uBxa3Shlg9F8fnCbvxK/eG3MHacV3URuPMrSXBiLxg
Z3Vms/EY96Jc5lP/Ooi2R6X/ExjqmAl3P51T+c8B5fWmcBcUr2Ok/5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IKw0KKP/32+IVQtQi0Cdd4Xn+GOdwiK1O5tmLOsbdJ1Fu/7xk9TND
TwIDAQABo4IBRjCCAUIwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
SwYIKwYBBQUHAQEEPzA9MDsGCCsGAQUFBzAChi9odHRwOi8vYXBwcy5pZGVudHJ1
c3QuY29tL3Jvb3RzL2RzdHJvb3RjYXgzLnA3YzAfBgNVHSMEGDAWgBTEp7Gkeyxx
+tvhS5B1/8QVYIWJEDBUBgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEEAYLfEwEB
ATAwMC4GCCsGAQUFBwIBFiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2VuY3J5cHQu
b3JnMDwGA1UdHwQ1MDMwMaAvoC2GK2h0dHA6Ly9jcmwuaWRlbnRydXN0LmNvbS9E
U1RST09UQ0FYM0NSTC5jcmwwHQYDVR0OBBYEFHm0WeZ7tuXkAXOACIjIGlj26Ztu
MA0GCSqGSIb3DQEBCwUAA4IBAQAKcwBslm7/DlLQrt2M51oGrS+o44+/yQoDFVDC
5WxCu2+b9LRPwkSICHXM6webFGJueN7sJ7o5XPWioW5WlHAQU7G75K/QosMrAdSW
9MUgNTP52GE24HGNtLi1qoJFlcDyqSMo59ahy2cI2qBDLKobkx/J3vWraV0T9VuG
WCLKTVXkcGdtwlfFRjlBz4pYg1htmf5X6DYO8A4jqv2Il9DjXA6USbW1FzXSLr9O
he8Y4IWS6wY7bCkjCWDcRQJMEhg76fsO3txE+FiYruq9RUWhiF1myv4Q6W+CyBFC
Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5
-----END CERTIFICATE-----
怎么了?
如果我只是要求 openssl 进行验证,它并不高兴:
18:09UTC:root@bard:~/TEMP# openssl verify -purpose sslserver -CAfile ./chain.pem ./cert.pem
C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 2 depth lookup: unable to get issuer certificate
error ./cert.pem: verification failed
等一下什么?
…这是否说明“ISRG Root X1”CA 证书未在本地安装?
搅浑水
Letsencrypt 将这两个证书包含在链文件中只是为了支持旧的 Android 系统。如果我尝试一个更简单的链,只包含由较新的“ISRG Root X1”签名的中间证书,会怎么样?因此,链文件中只有“MIIFFj…”…
18:21UTC:root@bard:~/TEMP# openssl verify -purpose sslserver -CAfile ./chainISRGX1.pem ./cert.pem
./cert.pem: OK
18:22UTC:root@bard:~/TEMP# echo $?
0
快乐的!
这使我相信,链文件中的第二个证书的存在导致了问题......
但我的 Openssl 已启用 Trusted_first 选项。
答案1
简短的回答是将-partial_chain
标志添加到我的 openssl 调用中。
这个 LetsEncrypt 社区主题有很多背景信息,https://community.letsencrypt.org/t/openssl-verification-fails-for-letsencrypt-issued-certificate/164800