pekahi

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCATemplate

func NewCATemplate(name string) *x509.Certificate

func NewClientTemplate

func NewClientTemplate(cn string, org string) *x509.Certificate

func NewServerTemplate

func NewServerTemplate(names []string, ips []net.IP) *x509.Certificate

Types

type CSR

type CSR struct {
	*x509.CertificateRequest
}

func (*CSR) MarshalJSON

func (c *CSR) MarshalJSON() ([]byte, error)

func (*CSR) UnmarshalJSON

func (c *CSR) UnmarshalJSON(data []byte) error

type Cert

type Cert struct {
	*x509.Certificate
}

Type aliases for JSON serialization (see json.go)

func (*Cert) MarshalJSON

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

func (*Cert) UnmarshalJSON

func (c *Cert) UnmarshalJSON(data []byte) error

type CertIO

type CertIO interface {
	LoadKey() ([]byte, error)
	LoadCert() ([]byte, error)
	LoadCSR() ([]byte, error)
	SaveKey(*pem.Block) error
	SaveCert(*pem.Block) error
	SaveCSR(*pem.Block) error
	KeyPath() string
	CertPath() string
	CSRPath() string
}

type Certificate

type Certificate struct {
	Key  *ecdsa.PrivateKey `json:"-"`
	Cert *Cert             `json:"cert"`
	CSR  *CSR              `json:"csr"`
	IO   CertIO            `json:"-"`
}

Certificate (request) and associated keypair Only supports ECDSA certificates for sign and auth

func (*Certificate) CSRPEM

func (c *Certificate) CSRPEM() *pem.Block

Get a CSR PEM

func (*Certificate) CertPEM

func (c *Certificate) CertPEM() *pem.Block

Get a cert PEM

func (*Certificate) CertPath

func (c *Certificate) CertPath() string

Get the certificate file path

func (*Certificate) KeyPEM

func (c *Certificate) KeyPEM() *pem.Block

Get a key PEM

func (*Certificate) KeyPath

func (c *Certificate) KeyPath() string

Get the key file path

func (*Certificate) Load

func (c *Certificate) Load() error

Try and load from saved state

func (*Certificate) MakeCSR

func (c *Certificate) MakeCSR(template *x509.Certificate) error

Generate a CSR if necessary (no available cert)

func (*Certificate) MakeKey

func (c *Certificate) MakeKey() error

Generate a key if necessary

func (*Certificate) Save

func (c *Certificate) Save() error

Save the current state

func (*Certificate) SelfSign

func (c *Certificate) SelfSign(template *x509.Certificate) error

Self sign a certificate if necessary

func (*Certificate) Sign

func (c *Certificate) Sign(s *Certificate, template *x509.Certificate) error

Sign another certificate

func (*Certificate) Signer

func (c *Certificate) Signer() crypto.Signer

Get a cert signer

type FileBundle

type FileBundle struct {
	Path string
}

func NewFileBundle

func NewFileBundle(path string) (*FileBundle, error)

func (*FileBundle) GetCA

func (b *FileBundle) GetCA(name string) (*Certificate, error)

func (*FileBundle) GetCertOrCSR

func (b *FileBundle) GetCertOrCSR(name string, template *x509.Certificate) (*Certificate, error)

func (*FileBundle) GetCertWithKey

func (b *FileBundle) GetCertWithKey(name string) (*Certificate, error)

func (*FileBundle) GetCertificate

func (b *FileBundle) GetCertificate(name string) *Certificate

type FileIO

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

func (FileIO) CSRPath

func (f FileIO) CSRPath() string

func (FileIO) CertPath

func (f FileIO) CertPath() string

func (FileIO) KeyPath

func (f FileIO) KeyPath() string

func (FileIO) Load

func (f FileIO) Load(path string) ([]byte, error)

func (FileIO) LoadCSR

func (f FileIO) LoadCSR() ([]byte, error)

func (FileIO) LoadCert

func (f FileIO) LoadCert() ([]byte, error)

func (FileIO) LoadKey

func (f FileIO) LoadKey() ([]byte, error)

func (FileIO) Save

func (f FileIO) Save(block *pem.Block, path string) error

func (FileIO) SaveCSR

func (f FileIO) SaveCSR(block *pem.Block) error

func (FileIO) SaveCert

func (f FileIO) SaveCert(block *pem.Block) error

func (FileIO) SaveKey

func (f FileIO) SaveKey(block *pem.Block) error

Jump to

Keyboard shortcuts

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