# Extract SPKI hash of the intermediate CA for a domain:
openssl s_client -connect <domain>:443 -showcerts </dev/null 2>/dev/null |\
  awk '/Certificate chain/{p=1} p' |\
  awk '/-----BEGIN CERTIFICATE-----/{c++; p=""; if(c==2)p=1} p{print}' |\
  openssl x509 -noout -pubkey |\
  openssl pkey -pubin -outform DER |\
  openssl dgst -sha256 -binary | base64

# Pin the intermediate CA (survives leaf renewals).
# Always include the root CA as a backup pin.
# Never pin the leaf certificate in production.
