Support SPKI Fingerprint Pinning

Support SPKI Fingerprint Pinning for TLSObject
This commit is contained in:
Yue Yin 2023-02-17 16:01:24 +08:00 committed by yuhan6665
parent 267d93f7bd
commit 03b8c094de
6 changed files with 169 additions and 23 deletions

View file

@ -2,6 +2,7 @@ package tls
import (
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/pem"
)
@ -34,3 +35,8 @@ func GenerateCertChainHash(rawCerts [][]byte) []byte {
}
return hashValue
}
func GenerateCertPublicKeyHash(cert *x509.Certificate) []byte {
out := sha256.Sum256(cert.RawSubjectPublicKeyInfo)
return out[:]
}