manager

package
v0.0.9 Latest Latest
Warning

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

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

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 schema.CreateCertRequest) (_ *schema.Cert, 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 schema.CreateCertRequest, ca schema.CertKey) (_ *schema.Cert, 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) GetCertChain

func (m *Manager) GetCertChain(ctx context.Context, cert schema.CertKey) (_ []schema.Cert, 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) GetPrivateKey

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

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

func (*Manager) InsertRootCert

func (m *Manager) InsertRootCert(ctx context.Context, pemValue string) (_ *schema.Cert, 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 schema.CertListRequest) (_ *schema.CertList, err error)

func (*Manager) RenewCA

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

func (*Manager) RenewCert

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

func (*Manager) UpdateCert

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

type Opt

type Opt func(*opt) error

Opt configures a Manager during construction.

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(key *rsa.PrivateKey, cert *x509.Certificate) Opt

WithRoot imports root certificate and matching RSA private key.

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