mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-12 16:59:38 +07:00
feat(juicity): support certificate pinning (#256)
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user