Documentation ¶
Index ¶
- Constants
- func Base64(data []byte) string
- func CSRToPem(cert *x509.CertificateRequest) []byte
- func CertAndKeyExists(fileName string) bool
- func CertExists(fileName string) bool
- func CertToPem(cert *x509.Certificate) []byte
- func FileExists(fileName string) bool
- func GenerateDHParams() ([]byte, error)
- func GenerateSelfSignedCertificate(cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
- func GenerateSignedCertificate(caKey *rsa.PrivateKey, caCert *x509.Certificate, cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
- func KubeconfigExists(fileName string) bool
- func PemToCertificate(data []byte) (*x509.Certificate, error)
- func PemToPrivateKey(data []byte) (*rsa.PrivateKey, error)
- func PrivateKey() (*rsa.PrivateKey, error)
- func PrivateKeyToPem(key *rsa.PrivateKey) []byte
- func PublicKeyToPem(key *rsa.PublicKey) ([]byte, error)
- func SelfSignedCertificate(cfg *CertCfg, key *rsa.PrivateKey) (*x509.Certificate, error)
- func SignedCertificate(cfg *CertCfg, csr *x509.CertificateRequest, key *rsa.PrivateKey, ...) (*x509.Certificate, error)
- type CA
- type CAList
- type Cert
- type CertCfg
- type Kubeconfig
Constants ¶
const ( ValidityOneDay = 24 * time.Hour ValidityOneYear = 365 * ValidityOneDay ValidityTenYears = 10 * ValidityOneYear )
Variables ¶
This section is empty.
Functions ¶
func CSRToPem ¶
func CSRToPem(cert *x509.CertificateRequest) []byte
CSRToPem converts an x509.CertificateRequest to a pem string
func CertAndKeyExists ¶
func CertExists ¶
func CertToPem ¶
func CertToPem(cert *x509.Certificate) []byte
CertToPem converts an x509.Certificate object to a pem string
func FileExists ¶
func GenerateDHParams ¶
func GenerateSelfSignedCertificate ¶
func GenerateSelfSignedCertificate(cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
GenerateSelfSignedCertificate generates a key/cert pair defined by CertCfg.
func GenerateSignedCertificate ¶
func GenerateSignedCertificate(caKey *rsa.PrivateKey, caCert *x509.Certificate, cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
GenerateSignedCertificate generate a key and cert defined by CertCfg and signed by CA.
func KubeconfigExists ¶
func PemToCertificate ¶
func PemToCertificate(data []byte) (*x509.Certificate, error)
PemToCertificate converts a data block to x509.Certificate.
func PemToPrivateKey ¶
func PemToPrivateKey(data []byte) (*rsa.PrivateKey, error)
PemToPrivateKey converts a data block to rsa.PrivateKey.
func PrivateKey ¶
func PrivateKey() (*rsa.PrivateKey, error)
PrivateKey generates an RSA Private key and returns the value
func PrivateKeyToPem ¶
func PrivateKeyToPem(key *rsa.PrivateKey) []byte
PrivateKeyToPem converts an rsa.PrivateKey object to pem string
func PublicKeyToPem ¶
PublicKeyToPem converts an rsa.PublicKey object to pem string
func SelfSignedCertificate ¶
func SelfSignedCertificate(cfg *CertCfg, key *rsa.PrivateKey) (*x509.Certificate, error)
SelfSignedCertificate creates a self signed certificate
func SignedCertificate ¶
func SignedCertificate( cfg *CertCfg, csr *x509.CertificateRequest, key *rsa.PrivateKey, caCert *x509.Certificate, caKey *rsa.PrivateKey, ) (*x509.Certificate, error)
SignedCertificate creates a new X.509 certificate based on a template.
Types ¶
type CA ¶
type CA struct { Key *rsa.PrivateKey Cert *x509.Certificate }
func GenerateCA ¶
GenerateCA generates a CA key pair with the given filename
type Cert ¶
type Cert struct { Parent *CA Key *rsa.PrivateKey Cert *x509.Certificate }
func GenerateCert ¶
type CertCfg ¶
type CertCfg struct { DNSNames []string ExtKeyUsages []x509.ExtKeyUsage IPAddresses []net.IP KeyUsages x509.KeyUsage Subject pkix.Name Validity time.Duration IsCA bool }
CertCfg contains all needed fields to configure a new certificate
type Kubeconfig ¶
func GenerateKubeconfig ¶
func GenerateKubeconfig(serverAddress, commonName, organization string, rootCA, signingCA *CA) (*Kubeconfig, error)
func (*Kubeconfig) WriteTo ¶
func (k *Kubeconfig) WriteTo(fileName string) error