not_go115.go 703 B

12345678910111213141516171819202122232425262728293031
  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. //go:build !go1.15
  5. // +build !go1.15
  6. package http2
  7. import (
  8. "context"
  9. "crypto/tls"
  10. )
  11. // dialTLSWithContext opens a TLS connection.
  12. func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) {
  13. cn, err := tls.Dial(network, addr, cfg)
  14. if err != nil {
  15. return nil, err
  16. }
  17. if err := cn.Handshake(); err != nil {
  18. return nil, err
  19. }
  20. if cfg.InsecureSkipVerify {
  21. return cn, nil
  22. }
  23. if err := cn.VerifyHostname(cfg.ServerName); err != nil {
  24. return nil, err
  25. }
  26. return cn, nil
  27. }