tlsutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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.

Jump to

Keyboard shortcuts

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