问题描述
我需要验证下载的 crl 实际上是由 CA 生成的,而不是被潜在攻击者修改的。 有没有办法用来自 linux os 的 openssl 命令来验证这一点?
换句话说,我需要根据其根 CA 验证 CRL 签名,我已经找到了这个链接,但对我帮助不大。 Verify CRL signature against its root CA
解决方法
openssl 有一个命令可以根据颁发的证书颁发机构验证下载的 crl 的签名。
openssl crl -verify -in <crl file> -CAfile < issue certificate or cert chain>
这是一个 hello-world 示例,用于根据 Google 颁发者 CA 证书验证 GOOGLE CRL
-
使用 wget 下载 google crl
wget http://crl.pki.goog/GTS1O1core.crl
-
下载的CRL为DER格式,转为PEM格式
openssl crl -inform DER -in GTS1O1core.crl -outform PEM -out google_crl.pem
-
下载谷歌证书链
OLDIFS=$IFS; IFS=':' certificates=$(openssl s_client -connect google.com:443 -showcerts -tlsextdebug -tls1 2>&1 </dev/null | sed -n '/-----BEGIN/,/-----END/ {/-----BEGIN/ s/^/:/; p}'); for certificate in ${certificates#:}; do echo $certificate | tee -a google-cert-chain.pem ; done; IFS=$OLDIFS
-
根据颁发的证书验证下载的 CRL(在 3 中下载的证书链中可用)
openssl crl -verify -in google_crl.pem -CAfile google-cert-chain.pem