generator

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package generator provides an interface and implementation to provision certificates.

Create an instance of certGenerator.

cg := SelfSignedCertGenerator{}

Generate the certificates.

certs, err := cg.Generate("foo.bar.com")
if err != nil {
	// handle error
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServiceToCommonName

func ServiceToCommonName(serviceNamespace, serviceName string) string

ServiceToCommonName generates the CommonName for the certificate when using a k8s service.

Example
fmt.Println(ServiceToCommonName("myservicenamespace", "myservicename"))
Output:

myservicename.myservicenamespace.svc

Types

type Artifacts

type Artifacts struct {
	// PEM encoded private key
	Key []byte
	// PEM encoded serving certificate
	Cert []byte
	// PEM encoded CA certificate
	CACert []byte
}

Artifacts hosts a private key, its corresponding serving certificate and the CA certificate that signs the serving certificate.

type CertGenerator

type CertGenerator interface {
	// Generate returns a Artifacts struct.
	Generate(CommonName string) (*Artifacts, error)
}

CertGenerator is an interface to provision the serving certificate.

type SelfSignedCertGenerator

type SelfSignedCertGenerator struct{}

SelfSignedCertGenerator implements the certGenerator interface. It provisions self-signed certificates.

func (*SelfSignedCertGenerator) Generate

func (cp *SelfSignedCertGenerator) Generate(commonName string) (*Artifacts, error)

Generate creates and returns a CA certificate, certificate and key for the server. serverKey and serverCert are used by the server to establish trust for clients, CA certificate is used by the client to verify the server authentication chain. The cert will be valid for 365 days.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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