ca

package
v0.0.0-...-c8cb849 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNil     = errs.Kind("nil")
	ErrInvalid = errs.Kind("invalid")

	ErrPublicKey   = errs.Entity("public key")
	ErrPrivateKey  = errs.Entity("private key")
	ErrCertificate = errs.Entity("certificate")
	ErrRepository  = errs.Entity("repository")
)

Variables

View Source
var (
	ErrNilRepository      = errs.WithDomain(errDomain, ErrNil, ErrRepository)
	ErrNilPrivateKey      = errs.WithDomain(errDomain, ErrNil, ErrPrivateKey)
	ErrInvalidPublicKey   = errs.WithDomain(errDomain, ErrInvalid, ErrPublicKey)
	ErrInvalidCertificate = errs.WithDomain(errDomain, ErrInvalid, ErrCertificate)
)

Functions

func WithLogHandler

func WithLogHandler(logger slog.Handler) cfg.Option[Config]

func WithLogger

func WithLogger(logger *slog.Logger) cfg.Option[Config]

func WithMetrics

func WithMetrics(m Metrics) cfg.Option[Config]

func WithTemplate

func WithTemplate(opts ...cfg.Option[certs.Template]) cfg.Option[Config]

func WithTracer

func WithTracer(tracer trace.Tracer) cfg.Option[Config]

Types

type CertificateAuthority

type CertificateAuthority struct {
	pb.UnimplementedCertificateAuthorityServer
	// contains filtered or unexported fields
}

func NewCertificateAuthority

func NewCertificateAuthority(
	repo Repository,
	privateKey *ecdsa.PrivateKey,
	opts ...cfg.Option[Config],
) (*CertificateAuthority, error)

func (*CertificateAuthority) CreateCertificate

func (*CertificateAuthority) DeleteCertificate

func (*CertificateAuthority) DeleteService

func (*CertificateAuthority) ListCertificates

func (*CertificateAuthority) RegisterService

func (*CertificateAuthority) RootCertificate

func (*CertificateAuthority) Shutdown

func (ca *CertificateAuthority) Shutdown(ctx context.Context) error

func (*CertificateAuthority) VerifyCertificate

type Config

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

type Metrics

type Metrics interface {
	IncServiceRegistries()
	IncServiceRegistryFailed()
	ObserveServiceRegistryLatency(ctx context.Context, duration time.Duration)
	IncServiceDeletions()
	IncServiceDeletionFailed()
	ObserveServiceDeletionLatency(ctx context.Context, duration time.Duration)
	IncCertificatesCreated(service string)
	IncCertificatesCreateFailed(service string)
	ObserveCertificatesCreateLatency(ctx context.Context, service string, duration time.Duration)
	IncCertificatesListed(service string)
	IncCertificatesListFailed(service string)
	ObserveCertificatesListLatency(ctx context.Context, service string, duration time.Duration)
	IncCertificatesDeleted(service string)
	IncCertificatesDeleteFailed(service string)
	ObserveCertificatesDeleteLatency(ctx context.Context, service string, duration time.Duration)
	IncCertificatesVerified(service string)
	IncCertificateVerificationFailed(service string)
	ObserveCertificateVerificationLatency(ctx context.Context, service string, duration time.Duration)
	IncRootCertificateRequests()
	IncRootCertificateRequestFailed()
	ObserveRootCertificateRequestLatency(ctx context.Context, duration time.Duration)
}

type Repository

type Repository interface {
	GetService(ctx context.Context, service string) (pubKey []byte, err error)
	CreateService(ctx context.Context, service string, pubKey []byte) (err error)
	DeleteService(ctx context.Context, service string) error

	ListCertificates(ctx context.Context, service string) (certs []*pb.CertificateResponse, err error)
	CreateCertificate(ctx context.Context, service string, cert []byte, expiry time.Time) error
	DeleteCertificate(ctx context.Context, service string, cert []byte) error

	Shutdown(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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