# Extract the full certificate chain for the API domain
openssl s_client -connect pocketboard-api.onrender.com:443 \
  -showcerts </dev/null 2>/dev/null

# The output shows the chain:
# Certificate 0: Leaf (pocketboard-api.onrender.com)
# Certificate 1: Intermediate CA (e.g., Let's Encrypt R3)
# Certificate 2: Root CA (e.g., ISRG Root X1)

# Extract the Subject Public Key Info (SPKI) hash for pinning:
# For the intermediate CA (Certificate 1):
openssl s_client -connect pocketboard-api.onrender.com: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

# Example output (yours will differ):
# jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=
