cert

package
v0.0.0-...-9d78121 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: LGPL-3.0 Imports: 13 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCA

func NewCA(commonName, UUID string, expiry time.Time, keyBits int) (certPEM, keyPEM string, err error)

NewCA generates a CA certificate/key pair suitable for signing server keys for an environment with the given name.

func NewClientCert

func NewClientCert(commonName, UUID string, expiry time.Time, keyBits int) (certPEM string, keyPEM string, err error)

NewClientCert generates a x509 client certificate used for https authentication sessions.

func NewLeaf

func NewLeaf(cfg *Config) (certPEM, keyPEM string, err error)

NewLeaf generates a certificate/key pair suitable for use by a server, leaf node, client authentication, etc. In order to generate certs for multiple purposes please consult the Config type.

func ParseCert

func ParseCert(certPEM string) (*x509.Certificate, error)

ParseCert parses the given PEM-formatted X509 certificate.

func ParseCertAndKey

func ParseCertAndKey(certPEM, keyPEM string) (*x509.Certificate, *rsa.PrivateKey, error)

ParseCertAndKey parses the given PEM-formatted X509 certificate and RSA private key.

Types

type Config

type Config struct {
	CommonName  string             // CommonName common name of the certificate
	UUID        string             // UUID for a specific model
	Expiry      time.Time          // Expiry when the certificate will expire
	CA          []byte             // CA certifiacte authority to add a new leaf cert to it
	CAKey       []byte             // CAKey private key of the CA to add a new leaf cert to it
	IsCA        bool               // IsCA if we want to generate new a CA cert
	Hostnames   []string           // Hostnames , list of hostnames for the certificate
	ExtKeyUsage []x509.ExtKeyUsage // ExtKeyUsage extra flags for special usage of the cert
	KeyBits     int                // KeyBits is used to set the lenght of the RSA key, default value 2048 bytes
	Client      bool               // generate client certificate for certificate authentication
}

Config type used for specifing different params for NewLeaf func This will effect the generation of certificates.

type GeneralName

type GeneralName struct {
	OID       asn1.ObjectIdentifier
	OtherName `asn1:"tag:0"`
}

GeneralName type for asn1 encoding

type GeneralNames

type GeneralNames struct {
	GeneralName `asn1:"tag:0"`
}

GeneralNames type for asn1 encoding

type OtherName

type OtherName struct {
	A string `asn1:"utf8"`
}

OtherName type for asn1 encoding

Jump to

Keyboard shortcuts

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