storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Certificate

type Certificate struct {
	Parents     []*Ref
	Fingerprint string
	X509        *x509.Certificate
	Children    []*Ref
}

Certificate represents an X.509 certificate in a format suitable for rendering to templates.

func (*Certificate) CanSign

func (c *Certificate) CanSign() bool

CanSign indicates whether this certificate may sign others.

func (*Certificate) KeyUsage

func (c *Certificate) KeyUsage() []string

type Config

type Config struct {

	// DataDir specifies where the data for the application should be stored.
	// An empty value indicates the current directory.
	DataDir string

	// Logger can be used to capture log messages.
	Logger *slog.Logger
}

Config provides configuration for Storage.

type CreateCertificateParams

type CreateCertificateParams struct {
	CommonName         string
	Organization       string
	OrganizationalUnit string
	Country            string
	Province           string
	Locality           string
	StreetAddress      string
	PostalCode         string
	Validity           string
	CanSign            bool
	CodeSigning        bool
	ClientAuth         bool
	ServerAuth         bool
	SANs               string
}

CreateCertificateParams provides CreateCertificate with parameters for creating a new X.509 certificate and private key.

type ExportCertificatePKCS12Params

type ExportCertificatePKCS12Params struct {
	Password string
}

ExportCertificatePKCS12Params provides ExportCertificatePKCS12 with parameters for exporting a certificate and its private key.

type Ref

type Ref struct {
	ID   string
	X509 *x509.Certificate
}

Ref stores an ID and certificate pair.

type Storage

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

Storage provides an abstraction to the certificate data stored on disk. All public methods are safe for use in multiple goroutines.

func New

func New(cfg *Config) (*Storage, error)

New creates a new Storage instance.

func (*Storage) CreateCertificate

func (s *Storage) CreateCertificate(
	certPath string,
	params *CreateCertificateParams,
) (string, error)

CreateCertificate creates a new certificate & private key. The certificate path to the newly created certificate is returned upon success.

func (*Storage) ExportCertificateChainPEM

func (s *Storage) ExportCertificateChainPEM(certPath string) ([]byte, error)

ExportCertificateChainPEM exports the specified certificate and its parents as a PEM-encoded file.

func (*Storage) ExportCertificatePEM

func (s *Storage) ExportCertificatePEM(certPath string) ([]byte, error)

ExportCertificatePEM exports the specified certificate as a PEM-encoded file.

func (*Storage) ExportCertificatePKCS12

func (s *Storage) ExportCertificatePKCS12(
	certPath string,
	params *ExportCertificatePKCS12Params,
) ([]byte, error)

ExportCertificatePKCS12 exports the specified certificate and its private key and CAs as a PKCS#12 file.

func (*Storage) ExportPrivateKeyPEM

func (s *Storage) ExportPrivateKeyPEM(certPath string) ([]byte, error)

ExportPrivateKeyPEM exports the private key of the specified certificate as a PEM-encoded file.

func (*Storage) ExportPublicKeyPEM

func (s *Storage) ExportPublicKeyPEM(certPath string) ([]byte, error)

ExportPublicKeyPEM exports the public key of the specified certificate as a PEM-encoded file.

func (*Storage) GetCertificate

func (s *Storage) GetCertificate(certPath string) (*Certificate, error)

GetCertificate attempts to return a certificate by its path.

func (*Storage) GetRootCertificates

func (s *Storage) GetRootCertificates() []*Ref

GetRootCertificates returns the root certificates.

func (*Storage) ValidateCertificate

func (s *Storage) ValidateCertificate(certPath string) error

ValidateCertificate attempts to validate the specified certificate.

Jump to

Keyboard shortcuts

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