manager

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	pg.PoolConn
	// contains filtered or unexported fields
}

Manager wraps a database connection pool scoped to the application schema.

func New

func New(ctx context.Context, pool pg.PoolConn, opts ...Opt) (*Manager, error)

New creates a Manager, ensures the schema exists, and bootstraps all database objects from the embedded objects.sql. If schemaName is empty the default schema is used.

func (*Manager) CreateCA

func (m *Manager) CreateCA(ctx context.Context, req cert.CreateCertRequest) (_ *cert.Certificate, err error)

CreateCA creates an intermediate certificate authority signed by the stored root certificate. If expiry is zero or negative, DefaultCACertExpiry is used and capped to the remaining validity of the root certificate. If subject is nil, the root certificate subject attributes are reused, but the common name always comes from req.Name.

func (*Manager) CreateCert

func (m *Manager) CreateCert(ctx context.Context, req cert.CreateCertRequest, ca cert.CertKey) (_ *cert.Certificate, err error)

CreateCert creates a leaf certificate signed by the explicit non-root CA certificate. If expiry is zero or negative, DefaultCertExpiry is used and capped to the remaining validity of the CA certificate. If subject is nil, the CA certificate subject attributes are reused, but the common name always comes from req.Name.

func (*Manager) CreateSubject added in v0.0.15

func (m *Manager) CreateSubject(ctx context.Context, meta cert.SubjectMeta) (_ *cert.Subject, err error)

CreateSubject stores a subject, which certificates can then be created with, or returns an identical one, when it's stored. It needs a field.

func (*Manager) DeleteSubject added in v0.0.15

func (m *Manager) DeleteSubject(ctx context.Context, id uint64) (_ *cert.Subject, err error)

DeleteSubject deletes a subject which no certificate uses, as deleting it would delete its certificates

func (*Manager) GetCert added in v0.0.15

func (m *Manager) GetCert(ctx context.Context, key cert.CertKey) (_ *cert.Certificate, err error)

GetCert returns the certificate with the name and serial, without its private key

func (*Manager) GetCertChain

func (m *Manager) GetCertChain(ctx context.Context, key cert.CertKey) (_ []cert.Certificate, err error)

GetCertChain returns the certificate row identified by key together with its issuer chain. PEM encoding is handled separately at the HTTP layer.

func (*Manager) GetLatestCert added in v0.0.15

func (m *Manager) GetLatestCert(ctx context.Context, name string) (_ *cert.Certificate, err error)

GetLatestCert returns the latest version of the certificate with the name, without its private key

func (*Manager) GetPrivateKey

func (m *Manager) GetPrivateKey(ctx context.Context, key cert.CertKey) (_ *cert.CertWithPrivateKey, err error)

GetPrivateKey returns the exact non-CA certificate row with its private key decrypted for direct use by callers.

func (*Manager) GetSubject added in v0.0.15

func (m *Manager) GetSubject(ctx context.Context, id uint64) (_ *cert.Subject, err error)

GetSubject returns a subject, with the number of certificates which use it

func (*Manager) HasRoot added in v0.0.15

func (m *Manager) HasRoot(ctx context.Context) (bool, error)

HasRoot is true when a root certificate is stored, without which certificate authorities can't be created

func (*Manager) InsertRootCert

func (m *Manager) InsertRootCert(ctx context.Context, pemValue string) (_ *cert.Certificate, err error)

InsertRootCert imports and stores the unique root certificate from a PEM bundle containing both the certificate and matching RSA private key.

func (*Manager) ListCerts

func (m *Manager) ListCerts(ctx context.Context, req cert.CertListRequest) (_ *cert.CertList, err error)

func (*Manager) ListSubjects added in v0.0.15

func (m *Manager) ListSubjects(ctx context.Context, req cert.SubjectListRequest) (_ *cert.SubjectList, err error)

ListSubjects returns a page of the subjects, in the order they were created, with the number of certificates which use each

func (*Manager) RenewCA

func (m *Manager) RenewCA(ctx context.Context, current cert.CertKey, req cert.RenewCertRequest) (_ *cert.Certificate, err error)

func (*Manager) RenewCert

func (m *Manager) RenewCert(ctx context.Context, current cert.CertKey, req cert.RenewCertRequest) (_ *cert.Certificate, err error)

func (*Manager) UpdateCert

func (m *Manager) UpdateCert(ctx context.Context, key cert.CertKey, meta cert.CertMeta) (_ *cert.Certificate, err error)

func (*Manager) UpdateSubject added in v0.0.15

func (m *Manager) UpdateSubject(ctx context.Context, id uint64, meta cert.SubjectMeta) (_ *cert.Subject, err error)

UpdateSubject changes the fields of a subject which no certificate uses, as a certificate's subject is in the certificate, which it would no longer be. A field which isn't set is kept, and an empty one removed.

type Opt

type Opt func(*opt) error

Opt configures a Manager during construction.

func WithChannel added in v0.0.15

func WithChannel(channel string) Opt

WithChannel notifies the channel of each change of a certificate, by its name, of a subject, by its identifier, and of an update of subjects, as a change of certificates, with triggers on their tables, which are dropped without a channel, so go-pg's pgbroadcaster can publish the changes, whatever makes them

func WithGeneratedRoot added in v0.0.15

func WithGeneratedRoot(commonName string) Opt

WithGeneratedRoot generates a self-signed root certificate, with the common name, when no root is stored and none is imported with WithRoot, so certificate authorities can be created without one. A stored root is kept.

func WithPassphrase

func WithPassphrase(version uint64, passphrase string) Opt

WithPassphrase registers an in-memory storage passphrase for a certificate passphrase version. Versions are uint64 and passphrases must be non-empty.

func WithRoot

func WithRoot(pemValue string) Opt

WithRoot imports a root certificate and its RSA private key, PEM encoded in one string, when the manager is created

func WithSchema

func WithSchema(name string) Opt

WithSchema sets the database schema name to use for all queries. If not set the default schema is used.

func WithTracer

func WithTracer(tracer trace.Tracer) Opt

WithTracer sets the OpenTelemetry tracer used for manager spans.

Jump to

Keyboard shortcuts

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