3 ms·
How do “modern” browsers check for certificate revocation
- 1vuio0pswjnm7 6y agoHere is a little script to demonstrate checking a CRL manually, using serial numbers. I am a text-only browser user and use command line TCP clients along with haproxy/stunnel to retrieve web pages instead of massive, complex "modern" browser just to establish TLS connection and send HTTP requests. How is a manual check via command line inferior to what "modern" browsers do. Are those large, complex programs really checking every certificate against a full list (CRL) of revoked certificates. (No, they are not.) crl.sh requires only openssl, curl and sed. Example usage: crl.sh example.com 93.184.216.34 Output: OK /#!/bin/sh case $# in [12]);;*)exec echo usage: $0 domainname \[ipaddr\];esac echo|openssl s_client -connect ${2:-$1}:443 -showcerts -servername $1 |sed -n -e '/./{/-BEGIN/,/-END/p;}' -e w$1.pem \ |openssl x509 -noout -text|sed -n '/./{/CRL Distribution Points/,/URI:/{/URI:/s/.*URI://; /\.crl$/{s/.*/url = &/;p;};};}'|curl -sK-|openssl crl -inform der -text|sed -n '/Serial/{s/.* //;p;}' >revoked.serials x=$(openssl x509 -noout -text < $1.pem |sed -n -e '/Serial/{n;s/[: ]//g;y/abcdef/ABCDEF/;p;}'); y=$(sed -n "/$x/{p;q;}" revoked.serials); echo;if test $y;then echo revoked;else echo OK;fi test ! -f $1.pem||rm $1.pem test ! -f revoked.serials||rm revoked.serials
- 1vuio0pswjnm7 6y agocase $# in [12]);;*)exec echo usage: $0 domainname \[ipaddr\];esac exec 2>/dev/null echo|openssl s_client -connect ${2:-$1}:443 -showcerts -servername $1 |sed -n -e '/./{/-BEGIN/,/-END/p;}' >1.pem openssl x509 -text -noout -in 1.pem|egrep -o '(CN = [^\"]*)|(DNS:[^,]*)'||exec echo fail: showcerts failed x=$(openssl x509 -noout -serial < 1.pem |sed 's/serial=//'); case $x in [0-9a-fA-F]*)echo serial: $x;;*)exec echo fail: no serial;esac; w=$(openssl x509 -text < 1.pem|grep -o "URI:[^\"]*\.crl"|sed 's/URI://;q'); case $w in http://*.crl|https://*.crl)echo crl: $w;;*)exec echo fail: no crl;esac echo url = $w |curl -sK- |openssl crl -inform der -text |sed -n '/Serial/{s/.* //;p;}' >revoked.serials z=$(sed -n '/^[0-9a-fA-F]*/{$=;}' revoked.serials); case $z in [1-9]*|[1-9][0-9]*)echo retrieved $z serials;;*)exec echo fail: could not retrieve revoked.serials list;esac if grep -i $x revoked.serials;then echo REVOKED;exit;else echo OK;fi test ! -f 1.pem||rm 1.pem test ! -f revoked.serials||rm revoked.serials
- 1vuio0pswjnm7 6y agoFurther reading: https://medium.com/@alexeysamoshkin/how-ssl-certificate-revocation-is-broken-in-practice-af3b63b9cb3 https://medium.com/@alexeysamoshkin/how-ssl-certificate-revo...