我试图了解如何检查 SSL 证书,并在证书链如下时考虑任何相关的已发布 CRL:
- 根 CA(没有 CRL 分发点)
- 中间 CA(通告由根 CA 签名的 CRL 分发点)
- 网站证书(宣传由中间 CA 签署的 CRL DP)
- 中间 CA(通告由根 CA 签名的 CRL 分发点)
因此,需要检查两个 CRL 列表。
碰巧BBC的网站配置如上所示,我们以此为例。我使用的文件在这个问题的末尾。
当我尝试在不检查 CRL 的情况下验证证书时,没关系:
$ openssl verify -CAfile intermediate_fullchain.pem bbc.pem
bbc.pem: OK
当我尝试从证书中给出的 CRL URL 检查 CRL 时,我收到一个错误:
$ openssl verify -crl_download -crl_check_all -CAfile intermediate_fullchain.pem bbc.pem
Error loading CRL from http://crl.globalsign.com/gsrsaovsslca2018.crl
C = GB, ST = London, L = London, O = British Broadcasting Corporation, CN = www.bbc.com
error 3 at 0 depth lookup: unable to get certificate CRL
error bbc.pem: verification failed
这对我来说很有意义,因为 crl 文件是 DER 格式,而 openssl 需要 PEM 格式,所以让我们下载 CRL 并将它们转换为 PEM。可以使用以下方法找到 CRL URL:
$ openssl x509 -in bbc.pem -text -noout
$ openssl x509 -in intermediate_fullchain.pem -text -noout
然后,我做了:
$ wget -O intermediate_crl.der http://crl.globalsign.com/gsrsaovsslca2018.crl
$ openssl crl -inform DER -in intermediate_crl.der -outform PEM -out intermediate_crl.pem
$ wget -O root_crl.der http://crl.globalsign.com/root-r3.crl
$ openssl crl -inform DER -in root_crl.der -outform PEM -out root_crl.pem
现在,我认为我拥有验证证书所需的一切:
$ openssl verify -crl_check_all -CRLfile intermediate_crl.pem -CRLfile root_crl.pem -CAfile intermediate_fullchain.pem bbc.pem
OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
error 3 at 2 depth lookup: unable to get certificate CRL
error bbc.pem: verification failed
但不是!验证仍然失败。我的问题:
- 上面命令中的问题到底是什么?这是否意味着 OpenSSL 期望根 CA 具有 CRL?
- 根据 CA 链中公布的两个 CRL 检查证书的正确方法是什么?
文件
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I7MOzZBjHZ9D3KIp+msmtgaJu7/KSEq2Eimp0PBzolbxiIBvmTJ0G9N
EeXysI6nG1L/j5+RWaQIS+r5xRsj
-----END CERTIFICATE-----
intermediate_fullchain.pem
: 中间 CA 证书,带有指向根 CA 的链:
-----BEGIN CERTIFICATE-----
MIIETjCCAzagAwIBAgINAe5fIh38YjvUMzqFVzANBgkqhkiG9w0BAQsFADBMMSAw
HgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFs
U2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0xODExMjEwMDAwMDBaFw0yODEx
MjEwMDAwMDBaMFAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52
LXNhMSYwJAYDVQQDEx1HbG9iYWxTaWduIFJTQSBPViBTU0wgQ0EgMjAxODCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKdaydUMGCEAI9WXD+uu3Vxoa2uP
UGATeoHLl+6OimGUSyZ59gSnKvuk2la77qCk8HuKf1UfR5NhDW5xUTolJAgvjOH3
idaSz6+zpz8w7bXfIa7+9UQX/dhj2S/TgVprX9NHsKzyqzskeU8fxy7quRU6fBhM
abO1IFkJXinDY+YuRluqlJBJDrnw9UqhCS98NE3QvADFBlV5Bs6i0BDxSEPouVq1
lVW9MdIbPYa+oewNEtssmSStR8JvA+Z6cLVwzM0nLKWMjsIYPJLJLnNvBhBWk0Cq
o8VS++XFBdZpaFwGue5RieGKDkFNm5KQConpFmvv73W+eka440eKHRwup08CAwEA
AaOCASkwggElMA4GA1UdDwEB/wQEAwIBhjASBgNVHRMBAf8ECDAGAQH/AgEAMB0G
A1UdDgQWBBT473/yzXhnqN5vjySNiPGHAwKz6zAfBgNVHSMEGDAWgBSP8Et/qC5F
JK5NUPpjmove4t0bvDA+BggrBgEFBQcBAQQyMDAwLgYIKwYBBQUHMAGGImh0dHA6
Ly9vY3NwMi5nbG9iYWxz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8fXvqWaN+JJ5U4nwbXPsnLJlkNc96wyOkm
DoMVxu9bi9IEYMpJpij2aTv2y8gokeWdimFXN6x0FNx04Druci8unPvQu7/1PQDh
BjPogiuuU6Y6FnOM3UEOIDrAtKeh6bJPkC4yYOlXy7kEkmho5TgmYHWyn3f/kRTv
riBJ/K1AFUjRAjFhGV64l++td7dkmnq/X8ET75ti+w1s4FRpFqkD2m7pg5NxdsZp
hYIXAgMBAAGjggEiMIIBHjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB
/zAdBgNVHQ4EFgQUj/BLf6guRSSuTVD6Y5qL3uLdG7wwHwYDVR0jBBgwFoAUYHtm
GkUNl8qJUC99BM00qP/8/UswPQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFo
dHRwOi8vb2NzcC5nbG9iYWxzaWduLmNvbS9yb290cjEwMwYDVR0fBCwwKjAooCag
JIYiaHR0cDovL2NybC5nbG9iYWxzaWduLmNvbS9yb290LmNybDBHBgNVHSAEQDA+
MDwGBFUdIAAwNDAyBggrBgEFBQcCARYmaHR0cHM6Ly93d3cuZ2xvYmFsc2lnbi5j
b20vcmVwb3NpdG9yeS8wDQYJKoZIhvcNAQELBQADggEBACNw6c/ivvVZrpRCb8RD
M6rNPzq5ZBfyYgZLSPFAiAYXof6r0V88xjPy847dHx0+zBpgmYILrMf8fpqHKqV9
D6ZX7qw7aoXW3r1AY/itpsiIsBL89kHfDwmXHjjqU5++BfQ+6tOfUBJ2vgmLwgtI
fR4uUfaNU9OrH0Abio7tfftPeVZwXwzTjhuzp3ANNyuXlava4BJrHEDOxcd+7cJi
WOx37XMiwor1hkOIreoTbv3Y/kIvuX1erRjvlJDKPSerJpSZdcfL03v3ykzTr1Eh
kluEfSufFT90y1HonoMOFm8b50bOI7355KKL0jlrqnkckSziYSQtjipIcJDEHsXo
4HA=
-----END CERTIFICATE-----
该
intermediate_fullchain.pem
文件不包含自签名根。我必须从 GlobalSign下载正确的文件,尽管您的机器可能已经安装了它,在这种情况下,您只需从上述链文件中删除错误的中间文件。您可以通过以下方式查看您的中间体:
这使:
您需要将链中的第二个证书替换为 Root CA 证书,或者如果您的系统安装了 Root,则将其删除。正是这个导致
openssl verify
找不到 CRL 并因此给您错误。您可以使用主题和授权密钥标识符扩展来确认链。证书的授权密钥标识符 (AKI) 应该是其签名者 (CA) 的主题密钥标识符 (SKI)。所以顶级BBC证书的AKI就是中间CA
F8:EF:7F:F2:CD:78:67:A8:DE:6F:8F:24:8D:88:F1:87:03:02:B3:EB
的SKI。C=BE, O=GlobalSign nv-sa, CN=GlobalSign RSA OV SSL CA 2018
该 CA 证书的 AKI 是上面第一段中链接的根 CA8F:F0:4B:7F:A8:2E:45:24:AE:4D:50:FA:63:9A:8B:DE:E2:DD:1B:BC
的 SKI 。OU=GlobalSign Root CA - R3, O=GlobalSign, CN=GlobalSign
但是,为了混淆问题,您文件中的第二个中间证书也有一个 SKI 和 Subject 与上面链接的根相同,但不是自签名的。该证书的 AKI 是您的信任锚存储中可能拥有的另一个根 CA 证书的 AKI(我的旧测试系统没有它,因此它对我来说失败了)。在不下载链接的根 CA 证书的情况下,您的路径因此有 4 个证书长(1 个最终实体、2 个中间体和一个根),因此需要三个 CRL - 根和一个由每个中间体颁发的证书。
使用正确的链接根,我得到:
如果您要找到第三个 CRL,那么您应该得到相同的结果。