certhandler

package
v0.0.0-...-b2cdabd Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("certificate not exist")

Functions

func RegisterPlugin

func RegisterPlugin(plugin string, newFunc NewPlugin)

RegisterPlugin registers module plugin.

Types

type CertInfo

type CertInfo struct {
	Issuer   string
	Serial   string
	CertURL  string
	KeyURL   string
	NotAfter time.Time
}

CertInfo certificate info.

type CertModule

type CertModule interface {
	ValidateCertificates() (validInfos []CertInfo, invalidCerts, invalidKeys []string, err error)
	SetOwner(password string) (err error)
	Clear() (err error)
	CreateKey(password, algorithm string) (key crypto.PrivateKey, err error)
	ApplyCertificate(certs []*x509.Certificate) (certInfo CertInfo, password string, err error)
	RemoveCertificate(certURL, password string) (err error)
	RemoveKey(certURL, password string) (err error)
	Close() (err error)
}

CertModule provides API to manage module certificates.

type CertStorage

type CertStorage interface {
	AddCertificate(certType string, cert CertInfo) (err error)
	GetCertificate(issuer, serial string) (cert CertInfo, err error)
	GetCertificates(certType string) (certs []CertInfo, err error)
	RemoveCertificate(certType, certURL string) (err error)
	RemoveAllCertificates(certType string) (err error)
}

CertStorage provides API to store/retrieve certificates info.

type Handler

type Handler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Handler update handler.

func New

func New(cfg *config.Config, storage CertStorage) (handler *Handler, err error)

New returns pointer to new Handler.

func (*Handler) ApplyCertificate

func (handler *Handler) ApplyCertificate(certType string, cert []byte) (certURL, serial string, err error)

ApplyCertificate applies certificate.

func (*Handler) Clear

func (handler *Handler) Clear(certType string) (err error)

Clear clears security storage.

func (*Handler) Close

func (handler *Handler) Close()

Close closes certificate handler.

func (*Handler) CreateKey

func (handler *Handler) CreateKey(certType, subject, password string) (csr []byte, err error)

CreateKey creates key pair.

func (*Handler) CreateSelfSignedCert

func (handler *Handler) CreateSelfSignedCert(certType, password string) (err error)

func (*Handler) GetCertTypes

func (handler *Handler) GetCertTypes() (certTypes []string)

GetCertTypes returns IAM cert types.

func (*Handler) GetCertificate

func (handler *Handler) GetCertificate(
	certType string, issuer []byte, serial string,
) (certURL, keyURL string, err error)

GetCertificate returns certificate info.

func (*Handler) SetOwner

func (handler *Handler) SetOwner(certType, password string) (err error)

SetOwner owns security storage.

type NewPlugin

type NewPlugin func(certType string, configJSON json.RawMessage) (module CertModule, err error)

NewPlugin plugin new function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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