Chore: http2 should use DialTLSContext and some tls handshake should with context

This commit is contained in:
Dreamacro
2022-08-13 12:35:39 +08:00
parent 71cad51e8f
commit 5940f62794
5 changed files with 17 additions and 16 deletions

View File

@ -40,7 +40,9 @@ type HttpOption struct {
func (h *Http) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) {
if h.tlsConfig != nil {
cc := tls.Client(c, h.tlsConfig)
err := cc.Handshake()
ctx, cancel := context.WithTimeout(context.Background(), C.DefaultTLSTimeout)
defer cancel()
err := cc.HandshakeContext(ctx)
c = cc
if err != nil {
return nil, fmt.Errorf("%s connect error: %w", h.addr, err)