Skip to content

Commit

Permalink
Clone TLS config before changing it
Browse files Browse the repository at this point in the history
  • Loading branch information
ghjm committed Feb 17, 2022
1 parent 745a1e1 commit fb2d7fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/netceptor/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ func (s *Netceptor) listen(ctx context.Context, service string, tlscfg *tls.Conf
tlscfg.NextProtos = []string{"netceptor"}
if tlscfg.ClientAuth == tls.RequireAndVerifyClientCert {
tlscfg.GetConfigForClient = func(hi *tls.ClientHelloInfo) (*tls.Config, error) {
clientTLSCfg := tlscfg.Clone()
remoteNode := strings.Split(hi.Conn.RemoteAddr().String(), ":")[0]
tlscfg.VerifyPeerCertificate = s.receptorVerifyFunc(tlscfg, remoteNode, VerifyClient)
clientTLSCfg.VerifyPeerCertificate = s.receptorVerifyFunc(tlscfg, remoteNode, VerifyClient)

return tlscfg, nil
}
Expand Down Expand Up @@ -292,8 +293,8 @@ func (s *Netceptor) DialContext(ctx context.Context, node string, service string
rAddr := s.NewAddr(node, service)
cfg := &quic.Config{
HandshakeIdleTimeout: 15 * time.Second,
MaxIdleTimeout: MaxIdleTimeoutForQuicConnections,
KeepAlive: KeepAliveForQuicConnections,
MaxIdleTimeout: MaxIdleTimeoutForQuicConnections,
KeepAlive: KeepAliveForQuicConnections,
}
if tlscfg == nil {
tlscfg = generateClientTLSConfig()
Expand Down

0 comments on commit fb2d7fc

Please sign in to comment.