netutil

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsSocketPaths

func AbsSocketPaths(addrs []string) ([]string, error)

func IsUnixSocketPath

func IsUnixSocketPath(addr string) bool

func LoadCACertPool

func LoadCACertPool(caFile string) (*x509.CertPool, error)

LoadCACertPool loads a PEM-encoded CA bundle for verifying a peer's certificate on an outbound connection (the server's cert, from a client's perspective) or, on an inbound mTLS listener, a connecting client's certificate.

func LoadClientCert

func LoadClientCert(certFile, keyFile string) (tls.Certificate, error)

LoadClientCert loads a client certificate/key pair for presenting on an outbound mTLS connection

func NewMultiAddrListener

func NewMultiAddrListener(network, address string, opts ListenerOptions) (net.Listener, error)

func NewMultiAddrTLSListener

func NewMultiAddrTLSListener(network, address string, getCertificateFunc func(*tls.ClientHelloInfo) (*tls.Certificate, error), opts ListenerOptions) (net.Listener, error)

NewMultiAddrTLSListener creates TLS listeners for all IP addresses that the hostname in the address resolves to. Similar to NewMultiAddrListener but with TLS.

func NewMultiAddrTLSListenerWithOptions

func NewMultiAddrTLSListenerWithOptions(network, address string, tlsOpts TLSOptions, opts ListenerOptions) (net.Listener, error)

NewMultiAddrTLSListenerWithOptions is NewMultiAddrTLSListener with control over client-certificate verification (mTLS), for listeners — such as the standalone IAM service's private endpoints — that must authenticate the connecting client, not just the server.

func RequireSecureTransport

func RequireSecureTransport(address string, hasMTLS bool) error

RequireSecureTransport enforces mTLS or unix socket a unix socket is always acceptable (the filesystem is the trust boundary), but a TCP address is only acceptable when mTLS (a server cert plus mandatory client-certificate verification) is actually configured for it

func ResolveHostnameIPs

func ResolveHostnameIPs(address string) ([]string, error)

Types

type CertStorage

type CertStorage struct {
	// contains filtered or unexported fields
}

func NewCertStorage

func NewCertStorage() *CertStorage

func (*CertStorage) GetCertificate

func (cs *CertStorage) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)

func (*CertStorage) SetCertificate

func (cs *CertStorage) SetCertificate(certFile string, keyFile string) error

type ListenerOptions

type ListenerOptions struct {
	SocketPerm os.FileMode
}

type MultiListener

type MultiListener struct {
	// contains filtered or unexported fields
}

MultiListener implements net.Listener and accepts connections from multiple underlying listeners.

func NewMultiListener

func NewMultiListener(listeners ...net.Listener) *MultiListener

func (*MultiListener) Accept

func (ml *MultiListener) Accept() (net.Conn, error)

func (*MultiListener) Addr

func (ml *MultiListener) Addr() net.Addr

func (*MultiListener) Close

func (ml *MultiListener) Close() error

type TLSOptions

type TLSOptions struct {
	GetCertificate    func(*tls.ClientHelloInfo) (*tls.Certificate, error)
	ClientCAs         *x509.CertPool
	RequireClientCert bool
}

TLSOptions configures the server-side tls.Config for NewMultiAddrTLSListenerWithOptions. A non-nil ClientCAs enables mTLS: inbound connections must present a certificate verified against that pool

Jump to

Keyboard shortcuts

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