Fix MITM vulnerability
A malicious actor was capable of intercepting quic traffic between the client and the server. The attack requires to use certificate pinning with CA-issued certificates.
This commit is contained in:
parent
922128e425
commit
9ec5b63386
1 changed files with 5 additions and 6 deletions
|
|
@ -275,13 +275,12 @@ func (c *clientConfig) fillTLSConfig(hyConfig *client.Config) error {
|
|||
if c.TLS.PinSHA256 != "" {
|
||||
nHash := normalizeCertHash(c.TLS.PinSHA256)
|
||||
hyConfig.TLSConfig.VerifyPeerCertificate = func(rawCerts [][]byte, _ [][]*x509.Certificate) error {
|
||||
for _, cert := range rawCerts {
|
||||
cert := rawCerts[0] // only check the end-entity cert hash in the chain of trust
|
||||
hash := sha256.Sum256(cert)
|
||||
hashHex := hex.EncodeToString(hash[:])
|
||||
if hashHex == nHash {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// No match
|
||||
return errors.New("no certificate matches the pinned hash")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue