tls

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package tls generates the local CA and wildcard certificate (via crypto/x509) and installs/removes trust in the system and NSS stores.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCertutil = errors.New("certutil is not installed")

ErrNoCertutil reports that the NSS tooling is absent, so the browser trust stores cannot be read at all.

Functions

func CACertLocation added in v0.4.0

func CACertLocation() (string, error)

CACertLocation resolves the CA certificate path without creating any directories, so query-only callers (`proximo config ca-path`) leave a host without proximo state untouched. The file may not exist yet (proximo not installed); callers that care must check.

func CACertPath

func CACertPath() (string, error)

CACertPath is the path to the local CA certificate (PEM).

func CAKeyPath

func CAKeyPath() (string, error)

CAKeyPath is the path to the local CA private key (PEM).

func CertPath

func CertPath() (string, error)

CertPath is the path to the wildcard leaf certificate (PEM).

func CertutilInstallable added in v0.13.0

func CertutilInstallable() bool

CertutilInstallable reports whether browser trust can be installed at all: the tooling is already here, or a package manager proximo supports can fetch it. Reading it before `install` mutates anything is what keeps a host that can never finish the trust step from being changed at all.

func CertutilRemedy added in v0.13.0

func CertutilRemedy() string

CertutilRemedy is the command that installs the NSS tooling, so a host that cannot even be asked about browser trust has a first step.

It answers per OS rather than per detected package manager: the host that needs this remedy is precisely the one where no package manager was found, and that host must not be told to run Homebrew because it is not a Mac.

func Dir

func Dir() (string, error)

Dir returns (creating if needed) the directory holding the CA and certificate material.

func EnsureCA

func EnsureCA() (certPath, keyPath string, err error)

EnsureCA generates a local CA on first use and reuses an existing one on subsequent runs. It returns the CA certificate and key file paths.

func InstallNSSTrust

func InstallNSSTrust(r platform.Runner) error

InstallNSSTrust adds the local CA to the NSS trust databases used by Firefox and Chrome-on-Linux. When certutil is missing it installs nss-tools first. certutil invocations go through the injected Runner; certutil discovery and bootstrap stay on the package helpers.

func InstallSystemTrust

func InstallSystemTrust(r platform.Runner) error

InstallSystemTrust adds the local CA to the OS system trust store using built-in OS tooling. Privileged operations go through the injected Runner so the install step is testable.

func IssueHostCert

func IssueHostCert(caCert *x509.Certificate, caKey *ecdsa.PrivateKey, hosts []string) (certPEM, keyPEM []byte, err error)

IssueHostCert generates a leaf certificate covering the exact hosts, signed by the CA, and returns it PEM-encoded. Validity stays under 398 days to satisfy the Apple/Chrome TLS policy (which rejects longer-lived leaf certs, and also rejects TLD-level wildcards like *.test — hence exact SANs, no wildcard).

func KeyPath

func KeyPath() (string, error)

KeyPath is the path to the wildcard leaf private key (PEM).

func LoadCA

func LoadCA(certPath, keyPath string) (*x509.Certificate, *ecdsa.PrivateKey, error)

LoadCA loads the CA certificate and private key from PEM files.

func NSSTrusted added in v0.13.0

func NSSTrusted(ctx context.Context) (found, total int, err error)

NSSTrusted reports how many of the NSS databases on this host hold the local CA, out of how many were found. Zero databases is not a failure: a machine with no Firefox or Chrome profile has nothing to answer with.

func Purge

func Purge() error

Purge deletes the local CA and certificate material from disk.

func RemoveNSSTrust

func RemoveNSSTrust(r platform.Runner) error

RemoveNSSTrust removes the local CA from all discovered NSS databases.

func RemoveSystemTrust

func RemoveSystemTrust(r platform.Runner) error

RemoveSystemTrust removes the local CA from the OS system trust store.

func SystemTrusted added in v0.13.0

func SystemTrusted(ctx context.Context) (bool, error)

SystemTrusted reports whether the local CA is in the OS system trust store. It only reads — no elevation, no repair — because a diagnosis that asks for a password is one nobody runs at the moment they need it most.

Types

This section is empty.

Jump to

Keyboard shortcuts

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