not_go115.go (703B)
1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !go1.15 6 // +build !go1.15 7 8 package http2 9 10 import ( 11 "context" 12 "crypto/tls" 13 ) 14 15 // dialTLSWithContext opens a TLS connection. 16 func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { 17 cn, err := tls.Dial(network, addr, cfg) 18 if err != nil { 19 return nil, err 20 } 21 if err := cn.Handshake(); err != nil { 22 return nil, err 23 } 24 if cfg.InsecureSkipVerify { 25 return cn, nil 26 } 27 if err := cn.VerifyHostname(cfg.ServerName); err != nil { 28 return nil, err 29 } 30 return cn, nil 31 }