Documentation
¶
Index ¶
- type Manager
- func (m *Manager) CreateCA(ctx context.Context, req cert.CreateCertRequest) (_ *cert.Certificate, err error)
- func (m *Manager) CreateCert(ctx context.Context, req cert.CreateCertRequest, ca cert.CertKey) (_ *cert.Certificate, err error)
- func (m *Manager) CreateSubject(ctx context.Context, meta cert.SubjectMeta) (_ *cert.Subject, err error)
- func (m *Manager) DeleteSubject(ctx context.Context, id uint64) (_ *cert.Subject, err error)
- func (m *Manager) GetCert(ctx context.Context, key cert.CertKey) (_ *cert.Certificate, err error)
- func (m *Manager) GetCertChain(ctx context.Context, key cert.CertKey) (_ []cert.Certificate, err error)
- func (m *Manager) GetLatestCert(ctx context.Context, name string) (_ *cert.Certificate, err error)
- func (m *Manager) GetPrivateKey(ctx context.Context, key cert.CertKey) (_ *cert.CertWithPrivateKey, err error)
- func (m *Manager) GetSubject(ctx context.Context, id uint64) (_ *cert.Subject, err error)
- func (m *Manager) HasRoot(ctx context.Context) (bool, error)
- func (m *Manager) InsertRootCert(ctx context.Context, pemValue string) (_ *cert.Certificate, err error)
- func (m *Manager) ListCerts(ctx context.Context, req cert.CertListRequest) (_ *cert.CertList, err error)
- func (m *Manager) ListSubjects(ctx context.Context, req cert.SubjectListRequest) (_ *cert.SubjectList, err error)
- func (m *Manager) RenewCA(ctx context.Context, current cert.CertKey, req cert.RenewCertRequest) (_ *cert.Certificate, err error)
- func (m *Manager) RenewCert(ctx context.Context, current cert.CertKey, req cert.RenewCertRequest) (_ *cert.Certificate, err error)
- func (m *Manager) UpdateCert(ctx context.Context, key cert.CertKey, meta cert.CertMeta) (_ *cert.Certificate, err error)
- func (m *Manager) UpdateSubject(ctx context.Context, id uint64, meta cert.SubjectMeta) (_ *cert.Subject, err error)
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
Manager wraps a database connection pool scoped to the application schema.
func New ¶
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
DeleteSubject deletes a subject which no certificate uses, as deleting it would delete its certificates
func (*Manager) GetCert ¶ added in v0.0.15
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
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
GetSubject returns a subject, with the number of certificates which use it
func (*Manager) HasRoot ¶ added in v0.0.15
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) 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 (*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
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
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 ¶
WithPassphrase registers an in-memory storage passphrase for a certificate passphrase version. Versions are uint64 and passphrases must be non-empty.
func WithRoot ¶
WithRoot imports a root certificate and its RSA private key, PEM encoded in one string, when the manager is created
func WithSchema ¶
WithSchema sets the database schema name to use for all queries. If not set the default schema is used.
func WithTracer ¶
WithTracer sets the OpenTelemetry tracer used for manager spans.