config

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides helpers for working with darvaza.org/x/tls.Store objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCACerts

func AddCACerts(ctx context.Context, s tls.StoreX509Writer, roots string) (int, error)

AddCACerts adds all given certificates as trusted roots to the given tls.Store. PEM content, a PEM fileName, or a directory containing PEM files.

func AddCert

func AddCert(ctx context.Context, s tls.StoreX509Writer, cert string) error

AddCert adds all given certificates to the specified tls.Store.

func AddCertPair

func AddCertPair(ctx context.Context, s tls.StoreX509Writer, key, cert string) error

AddCertPair adds a cert-key pair to the specified tls.Store.

func AddPrivateKey

func AddPrivateKey(ctx context.Context, s tls.StoreX509Writer, key string) error

AddPrivateKey adds a private key to the specified tls.Store.

func ImportCACerts

func ImportCACerts(ctx context.Context, s tls.StoreX509Writer, src x509utils.CertPool) (int, error)

ImportCACerts adds all CACerts in a given x509utils.CertPool to the specified tls.Store.

func ImportCerts

func ImportCerts(ctx context.Context, s tls.StoreX509Writer, src x509utils.CertPool) (int, error)

ImportCerts adds all Certs in a given x509utils.CertPool to the specified tls.Store.

Types

type Config

type Config struct {
	Logger slog.Logger

	Roots []string
	Keys  []string
	Certs []string

	Options []x509utils.ReadOption
}

Config provides an easy way to populate a tls.Store

func (*Config) AddCACerts

func (cfg *Config) AddCACerts(ctx context.Context, out tls.StoreX509Writer, value string,
	options ...x509utils.ReadOption) (int, error)

AddCACerts adds all given certificates as trusted roots to the given tls.Store. PEM content, a PEM fileName, or a directory containing PEM files.

func (*Config) AddCert

func (cfg *Config) AddCert(ctx context.Context, out tls.StoreX509Writer, value string,
	options ...x509utils.ReadOption) error

AddCert adds all given certificates to the specified tls.Store.

func (*Config) AddCertPair

func (cfg *Config) AddCertPair(ctx context.Context, out tls.StoreX509Writer, key, cert string,
	options ...x509utils.ReadOption) error

AddCertPair adds a cert-key pair to the specified tls.Store.

func (*Config) AddPrivateKey

func (cfg *Config) AddPrivateKey(ctx context.Context, out tls.StoreX509Writer, key string,
	options ...x509utils.ReadOption) error

AddPrivateKey adds a private key to the specified tls.Store.

func (*Config) Apply

func (cfg *Config) Apply(ctx context.Context, s tls.StoreX509Writer) error

Apply adds roots, keys and certs to the given tls.Store.

Jump to

Keyboard shortcuts

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