Skip to content

Instantly share code, notes, and snippets.

@fada21
fada21 / fetchSiteCertSha256Base64
Last active November 10, 2020 01:03
Given a domain name, the code below prints out the public keys in the chain as a SHA-256 hash using base 64 encoding.
# use like ./certs.sh www.google.com
#!/bin/bash
certs=`openssl s_client -servername $1 -host $1 -port 443 -showcerts </dev/null 2>/dev/null | sed -n '/Certificate chain/,/Server certificate/p'`
rest=$certs
while [[ "$rest" =~ '-----BEGIN CERTIFICATE-----' ]]
do
cert="${rest%%-----END CERTIFICATE-----*}-----END CERTIFICATE-----"
rest=${rest#*-----END CERTIFICATE-----}
echo `echo "$cert" | grep 's:' | sed 's/.*s:\(.*\)/\1/'`
<div class="page-overlay-wrapper" *ngIf="showSpinner">
<div class="bee-spinner"></div>
</div>