Check if SSL certificate is SHA1 or SHA2

23 Jun 2015 in TIL

I recently needed to check if the certificate I'd been provided with was SHA1 or SHA2. Stack Overflow helped, but here's a copy for posterity:

For a given website:

bash
openssl s_client -connect <host>:<port> < /dev/null 2>/dev/null | openssl x509 -text -in /dev/stdin | grep "Signature Algorithm"

For a file on disk:

bash
openssl x509 -text -in /path/to/public.crt | grep "Signature Algorithm"