Documentation ¶
Index ¶
- func EncodeCertPEM(ct *x509.Certificate) []byte
- func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte
- func NewPrivateKey() (*rsa.PrivateKey, error)
- func NewSignedCert(cfg cert.Config, key crypto.Signer, caCert *x509.Certificate, ...) (*x509.Certificate, error)
- func ServiceToCommonName(serviceNamespace, serviceName string) string
- func ValidCACert(key, cert, caCert []byte, dnsName string, time time.Time) bool
- type Artifacts
- type CertGenerator
- type SelfSignedCertGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeCertPEM ¶
func EncodeCertPEM(ct *x509.Certificate) []byte
EncodeCertPEM returns PEM-endcoded certificate data
func EncodePrivateKeyPEM ¶
func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte
EncodePrivateKeyPEM returns PEM-encoded private key data
func NewPrivateKey ¶
func NewPrivateKey() (*rsa.PrivateKey, error)
NewPrivateKey creates an RSA private key
func NewSignedCert ¶
func NewSignedCert(cfg cert.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error)
NewSignedCert creates a signed certificate using the given CA certificate and key
func ServiceToCommonName ¶
ServiceToCommonName generates the CommonName for the certificate when using a k8s service.
Types ¶
type Artifacts ¶
type Artifacts struct { // PEM encoded private key Key []byte // PEM encoded serving certificate Cert []byte // PEM encoded CA private key CAKey []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) // SetCA sets the PEM-encoded CA private key and CA cert for signing the generated serving cert. SetCA(caKey, caCert []byte) }
CertGenerator is an interface to provision the serving certificate.
type SelfSignedCertGenerator ¶
type SelfSignedCertGenerator struct {
// contains filtered or unexported fields
}
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.
func (*SelfSignedCertGenerator) SetCA ¶
func (cp *SelfSignedCertGenerator) SetCA(caKey, caCert []byte)
SetCA sets the PEM-encoded CA private key and CA cert for signing the generated serving cert.