Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeAndParsePEM(data []byte) (*x509.CertificateRequest, error)
- func GenerateCSR(config CSRConfig, key *rsa.PrivateKey) ([]byte, error)
- func GenerateCertificate(config BasicCertificateConfig, issuer *x509.Certificate, key *rsa.PrivateKey) ([]byte, error)
- func GetCACertPool(path string) (*x509.CertPool, error)
- func InitStorage(dirPath string) error
- func ReadCertificatePEM(filePath string) ([]byte, error)
- func ReadPrivateKey(filePath string) (*rsa.PrivateKey, error)
- func ReadPrivateKeyBytes(filePath string) ([]byte, error)
- func Sign(csr *x509.CertificateRequest, issuer *x509.Certificate, ...) ([]byte, error)
- func StorePath(filePath string) string
- func WriteCertificate(filePath string, certificate []byte) error
- func WritePrivateKey(filePath string, key *rsa.PrivateKey) error
- type BasicCertificateConfig
- type CSRConfig
Constants ¶
const ( RootKeyFile = "root-key.pem" RootCAFile = "root-cert.pem" )
File name constants
Variables ¶
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 ¶
GetCACertPool returns a x509.CertPool containing the RootCA generated by init-ca
func InitStorage ¶
InitStorage creates the storage directory, if dirPath does not already exist. This function also sets the storagePath global
func ReadCertificatePEM ¶
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 ¶
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 WriteCertificate ¶
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