feat(juicity): support certificate pinning (#256)

This commit is contained in:
mzz
2023-08-04 18:19:28 +08:00
committed by GitHub
parent 0c8cda4b28
commit 4d615205c0
4 changed files with 77 additions and 50 deletions

View File

@ -8,6 +8,7 @@ package common
import (
"crypto/aes"
"crypto/cipher"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"encoding/hex"
@ -495,3 +496,16 @@ func StringSet(list []string) map[string]struct{} {
}
return m
}
func GenerateCertChainHash(rawCerts [][]byte) (chainHash []byte) {
for _, cert := range rawCerts {
certHash := sha256.Sum256(cert)
if chainHash == nil {
chainHash = certHash[:]
} else {
newHash := sha256.Sum256(append(chainHash, certHash[:]...))
chainHash = newHash[:]
}
}
return chainHash
}