tls

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MPL-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package tls provides tls.Config generation and certificate management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...ConfigOptionFunc) (*tls.Config, error)

New returns a new TLS Configuration modified by any provided configuration options.

func WithCACertPEM

func WithCACertPEM(ca []byte) func(*tls.Config) error

WithCACertPEM declares a PEM-encoded CA Certificate to be used.

func WithClientAuthType

func WithClientAuthType(t Type) func(*tls.Config) error

WithClientAuthType declares the server's policy regardling TLS Client Authentication.

func WithClientCertificateProvider

func WithClientCertificateProvider(p CertificateProvider) func(*tls.Config) error

WithClientCertificateProvider declares a dynamic provider for the client certificate.

NOTE: specifying this option will CLEAR any configured Certificates, since they would otherwise override this option.

func WithDynamicClientCA added in v0.4.4

func WithDynamicClientCA(p CertificateProvider) func(*tls.Config) error

WithDynamicClientCA declares a dynamic client CA which will be updated on each client request.

This methods is for server-side TLS. For client TLS, build the new `tls.Config` on each request.

func WithKeypair

func WithKeypair(cert tls.Certificate) func(*tls.Config) error

WithKeypair declares a specific TLS keypair to be used. This can be called multiple times to add additional keypairs.

func WithMinVersion added in v0.6.3

func WithMinVersion(version uint16) func(*tls.Config) error

WithMinVersion sets the minimum TLS version to use.

func WithServerCertificateProvider

func WithServerCertificateProvider(p CertificateProvider) func(*tls.Config) error

WithServerCertificateProvider declares a dynamic provider for the server certificate.

NOTE: specifying this option will CLEAR any configured Certificates, since they would otherwise override this option.

Types

type CertificateProvider

type CertificateProvider interface {
	// GetCA returns the active root CA certificate(s).
	GetCA() ([]byte, error)

	// GetCACertPool returns the active root CA certificates as a certificate pool.
	GetCACertPool() (*x509.CertPool, error)

	// GetCertificate returns the current certificate matching the given client request.
	GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)

	// GetClientCertificate returns the current certificate to present to the server.
	GetClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error)
}

CertificateProvider describes an interface by which TLS certificates may be managed.

func NewRenewingCertificateProvider

func NewRenewingCertificateProvider(generator Generator, csrOptions ...talosx509.Option) (CertificateProvider, error)

NewRenewingCertificateProvider returns a new CertificateProvider which manages and updates its certificates using Generator.

type ConfigOptionFunc

type ConfigOptionFunc func(*tls.Config) error

ConfigOptionFunc describes a configuration option function for the TLS config.

type DynamicCertificate added in v0.6.4

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

DynamicCertificate is a certificate that can be reloaded from disk.

func NewDynamicCertificate added in v0.6.4

func NewDynamicCertificate(certFile, keyFile string) *DynamicCertificate

NewDynamicCertificate creates a new DynamicCertificate.

func (*DynamicCertificate) GetCertificate added in v0.6.4

func (c *DynamicCertificate) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate returns the current certificate.

It is suitable for use with tls.Config.GetCertificate.

func (*DynamicCertificate) Load added in v0.6.4

func (c *DynamicCertificate) Load() error

Load the initial certificate.

func (*DynamicCertificate) Watch added in v0.6.4

func (c *DynamicCertificate) Watch(ctx context.Context, logger *zap.Logger) error

Watch the certificate files for changes and reload them.

func (*DynamicCertificate) WatchWithRestarts added in v0.6.4

func (c *DynamicCertificate) WatchWithRestarts(ctx context.Context, logger *zap.Logger) error

WatchWithRestarts restarts the Watch on error.

type Generator

type Generator interface {
	Identity(csr *talosx509.CertificateSigningRequest) (ca, crt []byte, err error)
}

Generator describes an interface to sign the CSR.

type Type

type Type int

Type represents the TLS authentication type.

const (
	// Mutual configures the server's policy for TLS Client Authentication to
	// mutual TLS.
	Mutual Type = 1 << iota
	// ServerOnly configures the server's policy for TLS Client Authentication
	// to server only.
	ServerOnly
)

Jump to

Keyboard shortcuts

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