cert

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PemTypePrivateKey  = "PRIVATE KEY"
	PemTypeCertificate = "CERTIFICATE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cert

type Cert struct {
	Name    string  `json:"name"`              // Common Name
	Subject *uint64 `json:"subject,omitempty"` // Subject
	Signer  *Cert   `json:"signer,omitempty"`  // Signer
	// contains filtered or unexported fields
}

Certificate

func FromMeta added in v1.5.6

func FromMeta(meta *schema.Cert) (*Cert, error)

Create a certificate from metadata

func New

func New(opts ...Opt) (*Cert, error)

Create a new certificate

func Read

func Read(r io.Reader) (*Cert, error)

Read a certificate

func (Cert) CertMeta added in v1.5.6

func (c Cert) CertMeta() schema.CertMeta

Return metadata from a cert

func (*Cert) IsCA

func (c *Cert) IsCA() bool

Return true if the certificate is a certificate authority

func (Cert) MarshalJSON

func (c Cert) MarshalJSON() ([]byte, error)

func (*Cert) PrivateKey

func (c *Cert) PrivateKey() any

Return the private key, or nil

func (*Cert) PublicKey

func (c *Cert) PublicKey() any

Return the public key, or nil

func (Cert) String

func (c Cert) String() string

func (Cert) SubjectMeta

func (c Cert) SubjectMeta() schema.NameMeta

Return metadata from a cert

func (*Cert) Write

func (c *Cert) Write(w io.Writer) error

Output certificate as PEM format

func (*Cert) WritePrivateKey

func (c *Cert) WritePrivateKey(w io.Writer) error

Write the private key as PEM format

type CertManager

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

func NewCertManager

func NewCertManager(ctx context.Context, conn pg.PoolConn, opt ...Opt) (*CertManager, error)

Create a new certificate manager, with a root certificate authority

func (*CertManager) CreateCert added in v1.5.6

func (certmanager *CertManager) CreateCert(ctx context.Context, name string, opt ...Opt) (*schema.Cert, error)

Create a certificate with the given name, and a signer. The certificate is created in the database

func (*CertManager) CreateName added in v1.5.6

func (certmanager *CertManager) CreateName(ctx context.Context, meta schema.NameMeta) (*schema.Name, error)

func (*CertManager) DeleteCert added in v1.5.6

func (certmanager *CertManager) DeleteCert(ctx context.Context, name string) (*schema.Cert, error)

func (*CertManager) DeleteName

func (certmanager *CertManager) DeleteName(ctx context.Context, id uint64) (*schema.Name, error)

func (*CertManager) GetCert added in v1.5.6

func (certmanager *CertManager) GetCert(ctx context.Context, name string) (*schema.Cert, error)

func (*CertManager) GetName

func (certmanager *CertManager) GetName(ctx context.Context, id uint64) (*schema.Name, error)

func (*CertManager) ListNames

func (certmanager *CertManager) ListNames(ctx context.Context, req schema.NameListRequest) (*schema.NameList, error)

func (*CertManager) RegisterCert

func (certmanager *CertManager) RegisterCert(ctx context.Context, name string, meta schema.CertMeta) (*schema.Cert, error)

func (*CertManager) Root

func (certmanager *CertManager) Root() *Cert

Return the root certificate

func (*CertManager) UpdateCert added in v1.5.6

func (certmanager *CertManager) UpdateCert(ctx context.Context, name string, meta schema.CertMeta) (*schema.Cert, error)

func (*CertManager) UpdateName

func (certmanager *CertManager) UpdateName(ctx context.Context, id uint64, meta schema.NameMeta) (*schema.Name, error)

type Opt

type Opt func(*Cert) error

Opt is a function which applies options

func WithAddr

func WithAddr(addr ...string) Opt

Set hosts and IP addreses for the certificate

func WithAddress

func WithAddress(address, postcode string) Opt

Set address

func WithCA

func WithCA() Opt

Set as a CA certificate

func WithCommonName

func WithCommonName(name string) Opt

Set common name

func WithCountry

func WithCountry(country, state, city string) Opt

Set country

func WithDefaultKeyType added in v1.5.6

func WithDefaultKeyType() Opt

Create with a default key type

func WithEllipticKey

func WithEllipticKey(t string) Opt

Create an ECDSA key with one of the following curves: P224, P256, P384, P521

func WithExpiry

func WithExpiry(expires time.Duration) Opt

Set certificate expiry

func WithKeyType added in v1.5.6

func WithKeyType(t string) Opt

Create either an ECDSA or RSA key

func WithOrganization

func WithOrganization(org, unit string) Opt

Set organization

func WithRSAKey

func WithRSAKey(bits int) Opt

Create an RSA key with the specified number of bits

func WithRandomSerial

func WithRandomSerial() Opt

Set random serial number

func WithSerial

func WithSerial(serial *big.Int) Opt

Set serial number

func WithSigner

func WithSigner(signer *Cert) Opt

Set the signer for the certificate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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