tls

package
v0.0.0-...-b140147 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeCertificatePEM

func EncodeCertificatePEM(cert *x509.Certificate) []byte

EncodeCertificatePEM encodes the given certificate pem and returns bytes (base64).

func EncodePrivateKeyPEM

func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte

EncodePrivateKeyPEM encodes the given private key pem and returns bytes (base64).

func EncodePublicKeyPEM

func EncodePublicKeyPEM(key *rsa.PublicKey) ([]byte, error)

EncodePublicKeyPEM encodes the given public key pem and returns bytes (base64).

func NewPrivateKey

func NewPrivateKey() (*rsa.PrivateKey, error)

NewPrivateKey returns randomly generated RSA private key.

func NewSelfSignedCACertificate

func NewSelfSignedCACertificate(cfg CertConfig, key *rsa.PrivateKey) (*x509.Certificate, error)

NewSelfSignedCACertificate returns a self-signed CA certificate based on given configuration and private key. The certificate has one-year lease.

func NewSignedCertificate

func NewSignedCertificate(cfg CertConfig, key *rsa.PrivateKey, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*x509.Certificate, error)

NewSignedCertificate signs a certificate using the given private key, CA and returns a signed certificate. The certificate could be used for both client and server auth. The certificate has one-year lease.

func ParsePEMEncodedCACert

func ParsePEMEncodedCACert(pemdata []byte) (*x509.Certificate, error)

ParsePEMEncodedCACert parses a certificate from the given pemdata

func ParsePEMEncodedPrivateKey

func ParsePEMEncodedPrivateKey(pemdata []byte) (*rsa.PrivateKey, error)

ParsePEMEncodedPrivateKey parses a private key from given pemdata

Types

type AltNames

type AltNames struct {
	DNSNames []string
	IPs      []net.IP
}

AltNames contains the domain names and IP addresses that will be added to the API Server's x509 certificate SubAltNames field. The values will be passed directly to the x509.Certificate object.

func NewAltNames

func NewAltNames(addrs []string) AltNames

NewAltNames parses given addrs into either ip or dns name, and returns Altnames for them.

type CertConfig

type CertConfig struct {
	CommonName   string
	Organization []string
	AltNames     AltNames
}

CertConfig is a common struct containing fields to create a cert

Jump to

Keyboard shortcuts

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