gen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootKeyFile = "root-key.pem"
	RootCAFile  = "root-cert.pem"
)

File name constants

Variables

View Source
var AppFs = afero.NewOsFs()

AppFs OsFS is the default file system abstraction.

Functions

func DecodeAndParsePEM

func DecodeAndParsePEM(data []byte) (*x509.CertificateRequest, error)

DecodeAndParsePEM combines PEM decode and CSR parsing

func GenerateCSR

func GenerateCSR(config CSRConfig, key *rsa.PrivateKey) ([]byte, error)

GenerateCSR simplifies CSR generation. CSRs are returned as byte slices

func GenerateCertificate

func GenerateCertificate(
	config BasicCertificateConfig, issuer *x509.Certificate, key *rsa.PrivateKey) ([]byte, error)

GenerateCertificate simplifies certificate generation. Certificates are returned as a byte slice.

func GetCACertPool

func GetCACertPool(path string) (*x509.CertPool, error)

GetCACertPool returns a x509.CertPool containing the RootCA generated by init-ca

func InitStorage

func InitStorage(dirPath string) error

InitStorage creates the storage directory, if dirPath does not already exist. This function also sets the storagePath global

func ReadCertificatePEM

func ReadCertificatePEM(filePath string) ([]byte, error)

ReadCertificatePEM reads a PEM formatted file in

func ReadPrivateKey

func ReadPrivateKey(filePath string) (*rsa.PrivateKey, error)

ReadPrivateKey parses an RSA private key in PEM format and returns the result as an rsa.PrivateKey.

func ReadPrivateKeyBytes

func ReadPrivateKeyBytes(filePath string) ([]byte, error)

ReadPrivateKeyBytes parses an RSA private key in PEM format and returns the key as bytes

func Sign

func Sign(csr *x509.CertificateRequest, issuer *x509.Certificate, signingKey *rsa.PrivateKey) ([]byte, error)

Sign issues and signs a certificate per the csr provided.

func StorePath

func StorePath(filePath string) string

StorePath appends filePath to storagePath

func WriteCertificate

func WriteCertificate(filePath string, certificate []byte) error

WriteCertificate outputs a certificate to filePath in PEM format

func WritePrivateKey

func WritePrivateKey(filePath string, key *rsa.PrivateKey) error

WritePrivateKey output key to filePath in PEM format

Types

type BasicCertificateConfig

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

BasicCertificateConfig DI for certificate generation

func MakeCertificateConfig

func MakeCertificateConfig(name, country, state, locality, organization string,
	hosts, emailAddresses []string, ca bool) BasicCertificateConfig

MakeCertificateConfig packs a pkix.Name struct and returns a BasicCertificateConfig structure

type CSRConfig

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

CSRConfig DI for CSR generation

func MakeCSRConfig

func MakeCSRConfig(name, country, state, locality, organization string, hosts, emailAddresses []string) CSRConfig

MakeCSRConfig helps to generate the pkix.Name structure needed for CSR generation

Jump to

Keyboard shortcuts

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