certkit

package
v0.0.0-...-aa7c007 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrivateKeyBits is the number of bits to use when generating private keys
	PrivateKeyBits = 4096

	// DefaultYearsValid is the number of years to make a certificate valid for by default
	DefaultYearsValid = 1
)

Functions

func TemplateCertificate

func TemplateCertificate() *x509.Certificate

TemplateCertificate produces an x509.Certificate with the fields pre-populatedc with dummy values

func TemplateCertificateAuthority

func TemplateCertificateAuthority() *x509.Certificate

TemplateCertificateAuthority produces an x509.Certificate for a ca where the fields have been pre-populated with dummy values

Types

type Certificate

type Certificate interface {
	// Bytes produces the raw []byte of the cert
	Bytes() (*bytes.Buffer, error)

	// Certificate produces the x509.Certificate for the cert
	Certificate() *x509.Certificate

	// IsCA determines whether this cert is a ca certificate
	IsCA() bool

	// PEM produces the raw []byte of the cert in pem encoded format
	PEM() (*bytes.Buffer, error)

	// PrivateKey produces the rsa.PrivateKey for the cert
	PrivateKey() *rsa.PrivateKey

	// PrivateKeyPEM produces the raw []byte of the private key in pem encoded format
	PrivateKeyPEM() (*bytes.Buffer, error)
}

Certificate represents any x509 certificate and provides encoding methods

func NewCertificate

func NewCertificate(crt *x509.Certificate, ca Certificate) (Certificate, error)

NewCertificate generates a new certificate provided the x509.Certificate and signs it with the provided ca.CertificateAuthority

func NewCertificateAuthority

func NewCertificateAuthority(crt *x509.Certificate) (Certificate, error)

NewCertificateAuthority generates a private key and produces a Certificate for a CA given a valid x509.Certificate

Jump to

Keyboard shortcuts

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