pki

package
v0.0.0-...-55c0a6c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_CERT_VALIDITY = 200
	DEFAULT_ASYMKEYLEN    = 6168
	DEFAULT_SYMKEYLEN     = 256
	CERT_REVOKED          = "Cert has been Revoked"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CA

type CA struct {
	Organisation          string
	DefaultCertValidYears int
	Id                    []byte
	Cert                  *export.Cert
	Key                   *export.Key
	IntermediatePool      *x509.CertPool
	Revoked               *pkix.CertificateList
	// contains filtered or unexported fields
}

func LoadFromStorage

func LoadFromStorage(id []byte, con *data.StorageConnection) (*CA, error)

General Methods

func (*CA) ConnectStorage

func (ca *CA) ConnectStorage(con *data.StorageConnection)

type CertContainer

type CertContainer struct {
	Serial     *big.Int
	Crt        []byte
	Key        *rsa.PrivateKey
	ValidUntil time.Time
}

func (*CertContainer) ExportCert

func (c *CertContainer) ExportCert(passPhrase []byte) []byte

func (*CertContainer) ExportKey

func (c *CertContainer) ExportKey(passPhrase []byte) []byte

func (*CertContainer) GetX509Cert

func (c *CertContainer) GetX509Cert() (*x509.Certificate, error)

func (*CertContainer) LoadCert

func (c *CertContainer) LoadCert(pemBytes []byte, passPhrase []byte) error

func (*CertContainer) LoadKey

func (c *CertContainer) LoadKey(pemBytes []byte, passPhrase []byte) error

func (*CertContainer) PlainKey

func (c *CertContainer) PlainKey() []byte

func (*CertContainer) ToTls

func (c *CertContainer) ToTls() (tls.Certificate, error)

type CertRequest

type CertRequest struct {
	Email              string
	Country            string
	Location           string
	Organisation       string
	OrganizationalUnit string
	Province           string
	Address            string
}

type PKI

type PKI struct {
	Serial                *big.Int
	Organisation          string
	DefaultCertValidYears int

	Intermediate     map[string]*CertContainer
	IntermediatePool *x509.CertPool
	Revoked          []pkix.RevokedCertificate
	Crl              []byte
	CrlTTL           time.Time
	// contains filtered or unexported fields
}

func LoadPkiFromPEMBlock

func LoadPkiFromPEMBlock(pemEncoded []byte, key []byte) (root *PKI, e error)

func NewPki

func NewPki(organisation string, secure []byte, KeySize int) (root *PKI, e error)

* Create base Data

func (*PKI) AddIntermediate

func (p *PKI) AddIntermediate(c *CertContainer) error

func (*PKI) AddIntermediateFromExport

func (p *PKI) AddIntermediateFromExport(export []byte, key *rsa.PrivateKey) error

func (*PKI) CreateCRL

func (p *PKI) CreateCRL(ttl time.Time) (crlBytes []byte, err error)

func (*PKI) CreateIntermediate

func (p *PKI) CreateIntermediate(EmailAddress string, Title string, ValidYears int, KeySize int) (*CertContainer, error)

func (*PKI) Export

func (p *PKI) Export() ([]byte, error)

func (*PKI) GetCert

func (p *PKI) GetCert(parent *big.Int, KeySize int, cn string, req *CertRequest) (*CertContainer, error)

func (*PKI) IsRevoked

func (p *PKI) IsRevoked(cert *x509.Certificate) bool

func (*PKI) Revoke

func (p *PKI) Revoke(cert *x509.Certificate)

func (*PKI) ValidateByCaRaw

func (p *PKI) ValidateByCaRaw(derBytes []byte) (bool, error)

func (*PKI) Verify

func (p *PKI) Verify(cert *x509.Certificate, opts x509.VerifyOptions) error

type PKIExport

type PKIExport struct {
	Crt                   []byte
	Organisation          string
	DefaultCertValidYears int
	Key                   []byte
	Serial                big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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