certprovisioner

package
v0.1.12 Latest Latest
Warning

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

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

Documentation

Overview

Package certprovisioner provides an interface and implementation to provision certificates.

Create a implementation instance of certprovisioner.

cp := SelfSignedCertProvisioner{
	CommonName: "foo.bar.com"
}

Provision the certificates.

certs, err := cp.ProvisionServingCert()
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 CertProvisioner

type CertProvisioner interface {
	// ProvisionServingCert returns a Certs struct.
	ProvisionServingCert() (*Certs, error)
}

CertProvisioner is an interface to provision the serving certificate.

type Certs

type Certs struct {
	Key    []byte
	Cert   []byte
	CACert []byte
}

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

type SelfSignedCertProvisioner

type SelfSignedCertProvisioner struct {
	// Required Common Name
	CommonName string
}

SelfSignedCertProvisioner implements the CertProvisioner interface. It provisions self-signed certificates.

func (*SelfSignedCertProvisioner) ProvisionServingCert

func (cp *SelfSignedCertProvisioner) ProvisionServingCert() (*Certs, error)

ProvisionServingCert 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.

Jump to

Keyboard shortcuts

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