OpenSSL:根据在OS X上返回“无法获得颁发者证书”的CRL验证证书10.11.6 El Capitan

时间:2018-02-27 05:38:56

标签: macos openssl keychain chain certificate-revocation

我正在使用以下脚本在OS X 10.11.6 El Capitan上验证针对crl的证书。

host=wikipedia.org
port=443

openssl s_client -connect $host:$port 2>&1 < /dev/null | sed -n '/-----BEGIN/,/-----END/p' > $host.pem

crlurl=$(openssl x509 -noout -text -in $host.pem | grep -A 4 'X509v3 CRL Distribution Points' | grep URI |  grep -Eo '(http|https)://[^"]+')

curl $crlurl -o $host.crl.der

openssl crl -inform DER -in $host.crl.der -outform PEM -out $host.crl.pem

OLDIFS=$IFS; IFS=':' certificates=$(openssl s_client -connect "$host":"$port" -showcerts -tlsextdebug -tls1 2>&1 </dev/null | awk '/BEGIN CERT/ {p=1} ; p==1; /END CERT/ {p=0}' | sed 's/-----BEGIN/:-----BEGIN/g'); for certificate in ${certificates#:}; do echo $certificate | tee -a $host.chain.pem ; done; IFS=$OLDIFS

cat $host.chain.pem $host.crl.pem > $host.crl_chain.pem

openssl verify -crl_check -CAfile $host.crl_chain.pem $host.pem

它在ubuntu上工作正常但在尝试在OS X 10.11.6 El Capitan上运行时抛出以下错误。

wikipedia.org.pem: C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert SHA2 High Assurance Server CA
error 2 at 1 depth lookup:unable to get issuer certificate

将wikipedia.org与s_client联系返回:

Verify return code: 20 (unable to get local issuer certificate)

1 个答案:

答案 0 :(得分:0)

wikipedia.org的CA颁发者位于信任库中,即您的ubuntu中的 cacerts.pem 大多位于

lib/security/cacerts    
您的OS X 10.11.6 El Capitan中没有

&。信任库

$(/usr/libexec/java_home)/jre/lib/security/cacerts

使用以下命令查看SSL证书链,并尝试将wikipedia.org的根CA附加到您的Mac信任库中

openssl s_client -showcerts -servername wikipedia.org -connect wikipedia.org:443 
相关问题