blob: 908af1ab93c5c59ad02945b5f15706ba5642642c [file] [log] [blame]
khenaidoo26721882021-08-11 17:42:52 -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 uses tls.Dialer, added in Go 1.15, to open a TLS
16// connection.
17func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
18 dialer := &tls.Dialer{
19 Config: cfg,
20 }
21 cn, err := dialer.DialContext(ctx, network, addr)
22 if err != nil {
23 return nil, err
24 }
25 tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed
26 return tlsCn, nil
27}