tlsdialer

package module
v3.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 10 Imported by: 3

README

tlsdialer Travis CI Status Coverage Status GoDoc

package tlsdialer contains a customized version of crypto/tls.Dial that allows control over whether or not to send the ServerName extension in the client handshake.

v2 is the current version. Import and doc information on gopkg.in.

Documentation

Overview

package tlsdialer contains a customized version of crypto/tls.Dial that allows control over whether or not to send the ServerName extension in the client handshake.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(network, addr string, sendServerName bool, config *tls.Config) (*tls.Conn, error)

Like crypto/tls.Dial, but with the ability to control whether or not to send the ServerName extension in client handshakes through the sendServerName flag.

Note - if sendServerName is false, the VerifiedChains field on the connection's ConnectionState will never get populated. Use DialForTimings to get back a data structure that includes the verified chains.

func DialTimeout

func DialTimeout(dial func(net string, addr string, timeout time.Duration) (net.Conn, error), timeout time.Duration, network, addr string, sendServerName bool, config *tls.Config) (*tls.Conn, error)

Like Dial, but timing out after the given timeout.

Types

type ConnWithTimings

type ConnWithTimings struct {
	// Conn: the conn resulting from dialing
	Conn *tls.Conn
	// UConn: the utls conn resulting from dialing
	UConn *tls.UConn
	// ResolutionTime: the amount of time it took to resolve the address
	ResolutionTime time.Duration
	// ConnectTime: the amount of time that it took to connect the socket
	ConnectTime time.Duration
	// HandshakeTime: the amount of time that it took to complete the TLS
	// handshake
	HandshakeTime time.Duration
	// ResolvedAddr: the address to which our dns lookup resolved
	ResolvedAddr *net.TCPAddr
	// VerifiedChains: like tls.ConnectionState.VerifiedChains
	VerifiedChains [][]*x509.Certificate
}

A tls.Conn along with timings for key steps in establishing that Conn

func DialForTimings

func DialForTimings(dial func(net string, addr string, timeout time.Duration) (net.Conn, error), timeout time.Duration, network, addr string, sendServerName bool, config *tls.Config) (*ConnWithTimings, error)

Like DialWithDialer but returns a data structure including timings and the verified chains.

type Dialer

type Dialer struct {
	DoDial         func(net string, addr string, timeout time.Duration) (net.Conn, error)
	Timeout        time.Duration
	Network        string
	SendServerName bool

	// Force validation of a specific name other than the SNI name or dialed hostname
	ForceValidateName string

	// Must be provided if ClientHelloID is set to tls.HelloCustom. This field is ignored if
	// ClientHelloID is not set to tls.HelloCustom.
	ClientHelloSpec *tls.ClientHelloSpec

	ClientHelloID      tls.ClientHelloID
	ClientSessionState *tls.ClientSessionState
	Config             *tls.Config
}

Dialer is a configurable dialer that dials using tls

func (*Dialer) Dial

func (d *Dialer) Dial(network, addr string) (*tls.Conn, error)

Dial dials the given network and address.

func (*Dialer) DialForTimings

func (d *Dialer) DialForTimings(network, addr string) (*ConnWithTimings, error)

DialForTimings dials the given network and address and returns a ConnWithTimings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL