A certificate check asks whether any trusted CA vouches for the server. Pinning asks a narrower question: is this the exact key I saw before?
First compute the SHA-256 hash of the public key from the certificate, with OpenSSL:
openssl x509 -in server.pem -pubkey -noout \
| openssl pkey -pubin -outform der \
| openssl dgst -sha256 -binary | openssl base64
Then give that value to curl with the sha256// prefix:
curl --pinnedpubkey 'sha256//18RxxiyJbWkbwmzalr8RN37BYCM11PphupqQxtrLIY4=' \
https://nas.example.com/
If the key does not match, curl stops with exit code 90 before it sends anything. You can list several hashes separated by ;, which helps when you rotate keys.
I think this suits a script that talks to one box you control, like a backup target, and much less a public site. Let’s Encrypt clients often make a new key at every renewal, so a pin on a public site can break every few months. If you pin, renew with the same key or add the next key’s hash in advance. The normal certificate checks still run, so pinning comes on top of them.
Further reading: curl man page, curl docs: SSL certificate verification
Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get