set a net.Conn for tls.ClientHelloInfo.Conn used by GetCertificate (#4014)

This commit is contained in:
Marten Seemann 2023-08-03 20:33:19 -04:00 committed by Gaukas Wang
parent f7b03bf6b3
commit 18e4a9f516
2 changed files with 32 additions and 1 deletions

View file

@ -135,6 +135,13 @@ func NewCryptoSetupServer(
return gcfc(info)
}
}
if quicConf.TLSConfig.GetCertificate != nil {
gc := quicConf.TLSConfig.GetCertificate
quicConf.TLSConfig.GetCertificate = func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
info.Conn = &conn{localAddr: localAddr, remoteAddr: remoteAddr}
return gc(info)
}
}
cs.tlsConf = quicConf.TLSConfig
cs.conn = qtls.QUICServer(quicConf)