Documentation ¶
Overview ¶
Package tls defines and generates the tls assets based on its dependencies.
Index ¶
- Constants
- func CSRToPem(cert *x509.CertificateRequest) string
- func CertToPem(cert *x509.Certificate) string
- func GenerateCert(caKey *rsa.PrivateKey, caCert *x509.Certificate, cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
- func GenerateRootCA(key *rsa.PrivateKey, cfg *CertCfg) (*x509.Certificate, error)
- func GenerateRootCertKey(cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
- func GenerateSignedCert(cfg *CertCfg, csr *x509.CertificateRequest, key *rsa.PrivateKey, ...) (*x509.Certificate, error)
- func PemToCertificate(data []byte) (*x509.Certificate, error)
- func PemToPrivateKey(data []byte) (*rsa.PrivateKey, error)
- func PrivateKey() (*rsa.PrivateKey, error)
- func PrivateKeyToPem(key *rsa.PrivateKey) string
- func PublicKeyToPem(key *rsa.PublicKey) (string, error)
- func SelfSignedCACert(cfg *CertCfg, key *rsa.PrivateKey) (*x509.Certificate, error)
- func SignedCertificate(cfg *CertCfg, csr *x509.CertificateRequest, key *rsa.PrivateKey, ...) (*x509.Certificate, error)
- type CertCfg
- type CertKey
- type KeyPair
- type RootCA
- type Stock
- type StockImpl
- func (s *StockImpl) APIServerCertKey() asset.Asset
- func (s *StockImpl) APIServerProxyCertKey() asset.Asset
- func (s *StockImpl) AdminCertKey() asset.Asset
- func (s *StockImpl) AggregatorCA() asset.Asset
- func (s *StockImpl) ClusterAPIServerCertKey() asset.Asset
- func (s *StockImpl) EstablishStock(stock installconfig.Stock)
- func (s *StockImpl) EtcdCA() asset.Asset
- func (s *StockImpl) EtcdClientCertKey() asset.Asset
- func (s *StockImpl) IngressCertKey() asset.Asset
- func (s *StockImpl) KubeCA() asset.Asset
- func (s *StockImpl) KubeletCertKey() asset.Asset
- func (s *StockImpl) MCSCertKey() asset.Asset
- func (s *StockImpl) OpenshiftAPIServerCertKey() asset.Asset
- func (s *StockImpl) RootCA() asset.Asset
- func (s *StockImpl) ServiceAccountKeyPair() asset.Asset
- func (s *StockImpl) ServiceServingCA() asset.Asset
Constants ¶
const ( // KeyIndex is the index into a CertKey asset's contents at which the key // can be found. KeyIndex = 0 // CertIndex is the index into a CertKey asset's contents at which the // certificate can be found. CertIndex = 1 )
const ( // RootCAKeyName is the filename of the RootCAKey. RootCAKeyName = "root-ca.key" // RootCACertName is the filename of the RootCACert. RootCACertName = "root-ca.crt" // KubeCAKeyName is the filename of the KubeCAKey. KubeCAKeyName = "kube-ca.key" // KubeCACertName is the filename of the KubeCACert. KubeCACertName = "kube-ca.crt" // EtcdCAKeyName is the filename of the EtcdCAKey. EtcdCAKeyName = "etcd-client-ca.key" // EtcdCACertName is the filename of the EtcdCACert. EtcdCACertName = "etcd-client-ca.crt" // AggregatorCAKeyName is the filename of the AggregatorCAKey. AggregatorCAKeyName = "aggregator-ca.key" // AggregatorCACertName is the filename of the AggregatorCACert. AggregatorCACertName = "aggregator-ca.crt" // ServiceServingCAKeyName is the filename of the ServiceServingCAKey. ServiceServingCAKeyName = "service-serving-ca.key" // ServiceServingCACertName is the filename of the ServiceServingCACert. ServiceServingCACertName = "service-serving-ca.crt" // EtcdClientKeyName is the filename of the EtcdClientKey. EtcdClientKeyName = "etcd-client.key" // EtcdClientCertName is the filename of the EtcdClientCert. EtcdClientCertName = "etcd-client.crt" // AdminKeyName is the filename of the AdminKey. AdminKeyName = "admin.key" // AdminCertName is the filename of the AdminCert. AdminCertName = "admin.crt" // IngressKeyName is the filename of the IngressKey. IngressKeyName = "ingress.key" // IngressCertName is the filename of the IngressCert. IngressCertName = "ingress.crt" // APIServerKeyName is the filename of the APIServerKey. APIServerKeyName = "apiserver.key" // APIServerCertName is the filename of the APIServerCert. APIServerCertName = "apiserver.crt" // OpenshiftAPIServerKeyName is the filename of the OpenshiftAPIServerKey. OpenshiftAPIServerKeyName = "openshift-apiserver.key" // OpenshiftAPIServerCertName is the filename of the OpenshiftAPIServerCert. OpenshiftAPIServerCertName = "openshift-apiserver.crt" // APIServerProxyKeyName is the filename of the APIServerProxyKey. APIServerProxyKeyName = "apiserver-proxy.key" // APIServerProxyCertName is the filename of the APIServerProxyCert. APIServerProxyCertName = "apiserver-proxy.crt" // KubeletKeyName is the filename of the KubeletKey. KubeletKeyName = "kubelet.key" // KubeletCertName is the filename of the KubeletCert. KubeletCertName = "kubelet.crt" // MCSKeyName is the filename of the MCSKey. MCSKeyName = "machine-config-server.key" // MCSCertName is the filename of the MCSCert. MCSCertName = "machine-config-server.crt" // ClusterAPIServerCAKeyName is the filename of the ClusterAPIServerCAKey. ClusterAPIServerCAKeyName = "cluster-apiserver-ca.key" // ClusterAPIServerCACertName is the filename of the ClusterAPIServerCACert. ClusterAPIServerCACertName = "cluster-apiserver-ca.crt" // ServiceAccountPrivateKeyName is the filename of the ServiceAccountPrivateKey. ServiceAccountPrivateKeyName = "service-account.key" // ServiceAccountPublicKeyName is the filename of the ServiceAccountPublicKey. ServiceAccountPublicKeyName = "service-account.pub" )
const ( // ValidityTenYears sets the validity of a cert to 10 years. ValidityTenYears = time.Hour * 24 * 365 * 10 // ValidityThirtyMinutes sets the validity of a cert to 30 minutes. // This is for the kubelet bootstrap. ValidityThirtyMinutes = time.Minute * 30 )
Variables ¶
This section is empty.
Functions ¶
func CSRToPem ¶
func CSRToPem(cert *x509.CertificateRequest) string
CSRToPem converts an x509.CertificateRequest to a pem string
func CertToPem ¶
func CertToPem(cert *x509.Certificate) string
CertToPem converts an x509.Certificate object to a pem string
func GenerateCert ¶
func GenerateCert(caKey *rsa.PrivateKey, caCert *x509.Certificate, cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
GenerateCert creates a key, csr & a signed cert This is useful for apiserver and openshift-apiser cert which will be authenticated by the kubeconfig using root-ca.
func GenerateRootCA ¶
func GenerateRootCA(key *rsa.PrivateKey, cfg *CertCfg) (*x509.Certificate, error)
GenerateRootCA creates and returns the root CA
func GenerateRootCertKey ¶
func GenerateRootCertKey(cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error)
GenerateRootCertKey generates a root key/cert pair.
func GenerateSignedCert ¶
func GenerateSignedCert(cfg *CertCfg, csr *x509.CertificateRequest, key *rsa.PrivateKey, caKey *rsa.PrivateKey, caCert *x509.Certificate) (*x509.Certificate, error)
GenerateSignedCert generates a signed certificate.
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) string
PrivateKeyToPem converts an rsa.PrivateKey object to pem string
func PublicKeyToPem ¶
PublicKeyToPem converts an rsa.PublicKey object to pem string
func SelfSignedCACert ¶
func SelfSignedCACert(cfg *CertCfg, key *rsa.PrivateKey) (*x509.Certificate, error)
SelfSignedCACert Creates a self signed CA 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 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 CertKey ¶
type CertKey struct { // Common fields. Subject pkix.Name KeyUsages x509.KeyUsage ExtKeyUsages []x509.ExtKeyUsage Validity time.Duration KeyFileName string CertFileName string ParentCA asset.Asset IsCA bool AppendParent bool // Whether append the parent CA in the cert. // Some certs might need to set Subject, DNSNames and IPAddresses. GenDNSNames func(*types.InstallConfig) ([]string, error) GenIPAddresses func(*types.InstallConfig) ([]net.IP, error) GenSubject func(*types.InstallConfig) (pkix.Name, error) // contains filtered or unexported fields }
CertKey contains the private key and the cert that's signed by the parent CA.
func (*CertKey) Dependencies ¶
Dependencies returns the dependency of the the cert/key pair, which includes the parent CA, and install config if it depends on the install config for DNS names, etc.
type KeyPair ¶
KeyPair implements the Asset interface and generates an RSA public/private key pair.
func (*KeyPair) Dependencies ¶
Dependencies returns the dependency of an rsa private / public key pair.
type RootCA ¶
type RootCA struct{}
RootCA contains the private key and the cert that's self-signed as the root CA.
func (*RootCA) Dependencies ¶
Dependencies returns the dependency of the root-ca, which is empty.
type Stock ¶
type Stock interface { // RootCA is the asset that generates the root-ca key/cert pair. RootCA() asset.Asset // KubeCA is the asset that generates the kube-ca key/cert pair. KubeCA() asset.Asset // EtcdCA is the asset that generates the etcd-ca key/cert pair. EtcdCA() asset.Asset // AggregatorCA is the asset that generates the aggregator-ca key/cert pair. AggregatorCA() asset.Asset // ServiceServingCA is the asset that generates the service-serving-ca key/cert pair. ServiceServingCA() asset.Asset // EtcdClientCertKey is the asset that generates the etcd client key/cert pair. EtcdClientCertKey() asset.Asset // AdminCertKey is the asset that generates the admin key/cert pair. AdminCertKey() asset.Asset // IngressCertKey is the asset that generates the ingress key/cert pair. IngressCertKey() asset.Asset // APIServerCertKey is the asset that generates the API server key/cert pair. APIServerCertKey() asset.Asset // OpenshiftAPIServerCertKey is the asset that generates the Openshift API server key/cert pair. OpenshiftAPIServerCertKey() asset.Asset // APIServerProxyCertKey is the asset that generates the API server proxy key/cert pair. APIServerProxyCertKey() asset.Asset // KubeletCertKey is the asset that generates the kubelet key/cert pair. KubeletCertKey() asset.Asset // MCSCertKey is the asset that generates the MCS key/cert pair. MCSCertKey() asset.Asset // ClusterAPIServerCertKey is the asset that generates the cluster API server key/cert pair. ClusterAPIServerCertKey() asset.Asset // ServiceAccountKeyPair is the asset that generates the service-account public/private key pair. ServiceAccountKeyPair() asset.Asset }
Stock is the stock of TLS assets that can be generated.
type StockImpl ¶
type StockImpl struct {
// contains filtered or unexported fields
}
StockImpl implements the Stock interface for tls assets.
func (*StockImpl) APIServerCertKey ¶
APIServerCertKey is the asset that generates the API server key/cert pair.
func (*StockImpl) APIServerProxyCertKey ¶
APIServerProxyCertKey is the asset that generates the API server proxy key/cert pair.
func (*StockImpl) AdminCertKey ¶
AdminCertKey is the asset that generates the admin key/cert pair.
func (*StockImpl) AggregatorCA ¶
AggregatorCA is the asset that generates the aggregator-ca key/cert pair.
func (*StockImpl) ClusterAPIServerCertKey ¶
ClusterAPIServerCertKey is the asset that generates the cluster API server key/cert pair.
func (*StockImpl) EstablishStock ¶
func (s *StockImpl) EstablishStock(stock installconfig.Stock)
EstablishStock establishes the stock of assets.
func (*StockImpl) EtcdClientCertKey ¶
EtcdClientCertKey is the asset that generates the etcd client key/cert pair.
func (*StockImpl) IngressCertKey ¶
IngressCertKey is the asset that generates the ingress key/cert pair.
func (*StockImpl) KubeletCertKey ¶
KubeletCertKey is the asset that generates the kubelet key/cert pair.
func (*StockImpl) MCSCertKey ¶
MCSCertKey is the asset that generates the MCS key/cert pair.
func (*StockImpl) OpenshiftAPIServerCertKey ¶
OpenshiftAPIServerCertKey is the asset that generates the Openshift API server key/cert pair.
func (*StockImpl) ServiceAccountKeyPair ¶
ServiceAccountKeyPair is the asset that generates the service-account public/private key pair.
func (*StockImpl) ServiceServingCA ¶
ServiceServingCA is the asset that generates the service-serving-ca key/cert pair.