blob: e6c04cf7ac75c6bbbd34360f3ea2a894e839efaa [file] [log] [blame]
khenaidood948f772021-08-11 17:49:24 -04001// 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
8package http2
9
10import (
11 "context"
12 "crypto/tls"
13)
14
15// dialTLSWithContext opens a TLS connection.
16func (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}