github.com/Kolosok86/http@v0.1.2/http2/not_go115.go (about)

     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  
    13  	tls "github.com/refraction-networking/utls"
    14  )
    15  
    16  // dialTLSWithContext opens a TLS connection.
    17  func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
    18  	cn, err := tls.Dial(network, addr, cfg)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  	if err := cn.Handshake(); err != nil {
    23  		return nil, err
    24  	}
    25  	if cfg.InsecureSkipVerify {
    26  		return cn, nil
    27  	}
    28  	if err := cn.VerifyHostname(cfg.ServerName); err != nil {
    29  		return nil, err
    30  	}
    31  	return cn, nil
    32  }