pki

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCert

func GenerateCert(ca *CA, name string, validFrom string, validFor time.Duration, isCA bool, rsaBits int, ecdsaCurve string, usage x509.ExtKeyUsage) (cert, key []byte, err error)

Types

type CA

type CA struct {
	*Entity
	NextSerial *big.Int
}

CA is a certificate key pair which is able to issue new client-, server- and ca-certificates

func NewCA

func NewCA(certPem, keyPem []byte, nextSerial *big.Int) (*CA, error)

NewCA creates a new CA from a key/cert pair and a nextSerial number

func NewSelfSignedCA

func NewSelfSignedCA(caID string, curve string, rsaBits int) (*CA, error)

NewSelfSignedCA creates a new self-signed CA // curve can be one of: * P224 * P256 * P384 * P521 rsaBits should be one of * 0 (if curve is specified) * 1024 * 2048 * 4096

func (*CA) GetNextSerial

func (ca *CA) GetNextSerial() *big.Int

GetNextSerial returns the next free serial number and increases the internal value

func (*CA) IssueCA

func (ca *CA) IssueCA(name, curve string, rsaBits int) (cert, key []byte, err error)

IssueCA issues a new ca certificate curve can be one of: * P224 * P256 * P384 * P521 rsaBits should be one of * 0 (if curve is specified) * 1024 * 2048 * 4096

func (*CA) IssueClient

func (ca *CA) IssueClient(name, curve string, rsaBits int) (cert, key []byte, err error)

IssueClient issues a new client certificate curve can be one of: * P224 * P256 * P384 * P521 rsaBits should be one of * 0 (if curve is specified) * 1024 * 2048 * 4096

func (*CA) IssueServer

func (ca *CA) IssueServer(name, curve string, rsaBits int) (cert, key []byte, err error)

IssueServer issues a new server certificate curve can be one of: * P224 * P256 * P384 * P521 rsaBits should be one of * 0 (if curve is specified) * 1024 * 2048 * 4096

type Entity

type Entity struct {
	Cert      *x509.Certificate
	Key       interface{}
	Algorithm x509.PublicKeyAlgorithm
}

func NewEntityFromDER

func NewEntityFromDER(certDer, keyDer []byte, algo x509.PublicKeyAlgorithm) (*Entity, error)

func NewEntityFromFile

func NewEntityFromFile(cert, key string) (*Entity, error)

func NewEntityFromPEM

func NewEntityFromPEM(cert []byte, key []byte) (*Entity, error)

func (*Entity) GetCertAsDER

func (entity *Entity) GetCertAsDER() ([]byte, error)

func (*Entity) GetCertAsPEM

func (entity *Entity) GetCertAsPEM() ([]byte, error)

func (*Entity) GetKeyAsDER

func (entity *Entity) GetKeyAsDER() ([]byte, error)

func (*Entity) GetKeyAsPEM

func (entity *Entity) GetKeyAsPEM() ([]byte, error)

Jump to

Keyboard shortcuts

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