Skip to content

Commit f1c485f

Browse files
committed
fix: fix tls versions for non-ech connections
1 parent 167c602 commit f1c485f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

u_conn.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ func (uconn *UConn) MarshalClientHello() error {
576576
inner.supportedSignatureAlgorithms = uconn.HandshakeState.Hello.SupportedSignatureAlgorithms
577577
inner.sessionId = uconn.HandshakeState.Hello.SessionId
578578
inner.supportedCurves = uconn.HandshakeState.Hello.SupportedCurves
579-
inner.supportedVersions = []uint16{VersionTLS13} // hardcode tls 1.3 as it is the only supported version currently
580579

581580
ech.innerHello = inner
582581

@@ -588,14 +587,12 @@ func (uconn *UConn) MarshalClientHello() error {
588587
return fmt.Errorf("sni extension missing while attempting ECH")
589588
}
590589

591-
oldSNI := uconn.Extensions[sniExtIdex]
592590
uconn.Extensions[sniExtIdex] = &SNIExtension{
593591
ServerName: string(ech.config.PublicName),
594592
}
595593

596594
uconn.computeAndUpdateOuterECHExtension(inner, ech, true)
597595

598-
uconn.Extensions[sniExtIdex] = oldSNI
599596
uconn.echCtx = ech
600597
return nil
601598
}
@@ -761,6 +758,10 @@ func (uconn *UConn) SetTLSVers(minTLSVers, maxTLSVers uint16, specExtensions []T
761758
}
762759

763760
uconn.HandshakeState.Hello.SupportedVersions = makeSupportedVersions(minTLSVers, maxTLSVers)
761+
if uconn.config.EncryptedClientHelloConfigList == nil {
762+
uconn.config.MinVersion = minTLSVers
763+
uconn.config.MaxVersion = maxTLSVers
764+
}
764765

765766
return nil
766767
}

0 commit comments

Comments
 (0)