Documentation
¶
Overview ¶
Package tlsutil provides shared TLS configuration helpers used by transports (mqtt, httppush) and drivers (modbus-tls) to avoid duplicating certificate-loading boilerplate.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTLSConfig ¶
func BuildTLSConfig(opts TLSOptions) (*tls.Config, error)
BuildTLSConfig constructs a *tls.Config with TLS 1.2+ minimum, optional CA pool, and optional client certificate. Returns nil if no TLS files are provided and no ServerName is set (indicating TLS is not needed).
func LoadCertPool ¶
LoadCertPool reads a PEM-encoded CA certificate file and returns a CertPool containing the parsed certificates. The pool is suitable for assignment to tls.Config.RootCAs.
func LoadClientCert ¶
func LoadClientCert(certFile, keyFile string) (tls.Certificate, error)
LoadClientCert loads a PEM-encoded client certificate and private key pair. Both files must be provided.
Types ¶
type TLSOptions ¶
type TLSOptions struct {
ServerName string // for hostname verification (empty = skip)
CAFile string // CA certificate PEM file (empty = system roots)
CertFile string // client cert PEM file (empty = no client cert)
KeyFile string // client key PEM file (empty = no client cert)
}
TLSOptions configures BuildTLSConfig.