certs

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package certs provides TLS configuration building from explicit certificate file paths. It has no environment or deployment assumptions — callers supply all paths directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CACert  string // path to CA certificate file
	TLSCert string // path to TLS certificate file
	TLSKey  string // path to TLS private key file
}

Config holds explicit file paths for the CA cert, TLS cert, and TLS key. The same cert/key pair is used for both client and server roles in mTLS.

func (Config) IsSet

func (c Config) IsSet() bool

IsSet reports whether all three certificate paths are set.

func (Config) ServerTLSConfig

func (c Config) ServerTLSConfig() (*tls.Config, error)

ServerTLSConfig builds a server-side tls.Config from the explicit file paths in c. Certificates is set so the server can present its certificate during the TLS handshake. ClientAuth and ClientCAs are set to require and verify the client certificate.

func (Config) TLSConfig

func (c Config) TLSConfig(serverName string) (*tls.Config, error)

TLSConfig builds a client-side tls.Config from the explicit file paths in c. RootCAs is set to verify the server certificate. GetClientCertificate is used instead of Certificates to ensure the client always presents its certificate during the TLS handshake. With the Certificates field, Go's TLS stack only selects a certificate if its issuer matches the acceptable CA list sent by the server in its CertificateRequest message. When no match is found, Go silently sends an empty certificate list, causing the server to reject the connection with "certificate required". GetClientCertificate bypasses this matching and unconditionally returns the certificate, leaving verification to the server.

func (Config) Validate

func (c Config) Validate() error

Validate checks that all three certificate paths are set. Either all must be non-empty or none — partial configuration is an error.

Jump to

Keyboard shortcuts

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