Documentation
¶
Overview ¶
Package tls provides the TLS transport.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapConn ¶
func WrapConn(ctx context.Context, conn transport.StreamConn, serverName string, options ...ClientOption) (transport.StreamConn, error)
WrapConn wraps a transport.StreamConn in a TLS connection.
Types ¶
type ClientConfig ¶
type ClientConfig struct { // The host name for the Server Name Indication (SNI). ServerName string // The hostname to use for certificate validation. CertificateName string // The protocol id list for protocol negotiation (ALPN). NextProtos []string // The cache for sessin resumption. SessionCache tls.ClientSessionCache }
ClientConfig encodes the parameters for a TLS client connection.
type ClientOption ¶
type ClientOption func(serverName string, config *ClientConfig)
ClientOption allows configuring the parameters to be used for a client TLS connection.
func IfHost ¶ added in v0.0.11
func IfHost(matchHost string, option ClientOption) ClientOption
IfHost applies the given option if the host matches the dialed one.
func WithALPN ¶
func WithALPN(protocolNameList []string) ClientOption
WithALPN sets the protocol name list for Application-Layer Protocol Negotiation (ALPN). The list of protocol IDs can be found in IANA's registry.
func WithCertificateName ¶
func WithCertificateName(hostname string) ClientOption
WithCertificateName sets the hostname to be used for the certificate cerification. If absent, defaults to the dialed hostname.
func WithSNI ¶
func WithSNI(hostName string) ClientOption
WithSNI sets the host name for Server Name Indication (SNI). If absent, defaults to the dialed hostname. Note that this only changes what is sent in the SNI, not what host is used for certificate verification.
func WithSessionCache ¶
func WithSessionCache(sessionCache tls.ClientSessionCache) ClientOption
WithSessionCache sets the tls.ClientSessionCache to enable session resumption of TLS connections.
type StreamDialer ¶
type StreamDialer struct {
// contains filtered or unexported fields
}
StreamDialer is a transport.StreamDialer that uses TLS to wrap the inner StreamDialer.
func NewStreamDialer ¶
func NewStreamDialer(baseDialer transport.StreamDialer, options ...ClientOption) (*StreamDialer, error)
NewStreamDialer creates a StreamDialer that wraps the connections from the baseDialer with TLS configured with the given options.
func (*StreamDialer) DialStream ¶ added in v0.0.12
func (d *StreamDialer) DialStream(ctx context.Context, remoteAddr string) (transport.StreamConn, error)
DialStream implements transport.StreamDialer.DialStream.