forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clusterapiservercertkey.go
44 lines (35 loc) · 1.31 KB
/
clusterapiservercertkey.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package tls
import (
"crypto/x509"
"crypto/x509/pkix"
"github.com/openshift/installer/pkg/asset"
)
// ClusterAPIServerCertKey is the asset that generates the cluster API server key/cert pair.
type ClusterAPIServerCertKey struct {
CertKey
}
var _ asset.Asset = (*ClusterAPIServerCertKey)(nil)
// 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.
func (a *ClusterAPIServerCertKey) Dependencies() []asset.Asset {
return []asset.Asset{
&AggregatorCA{},
}
}
// Generate generates the cert/key pair based on its dependencies.
func (a *ClusterAPIServerCertKey) Generate(dependencies asset.Parents) error {
aggregatorCA := &AggregatorCA{}
dependencies.Get(aggregatorCA)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "clusterapi.openshift-cluster-api.svc", OrganizationalUnit: []string{"bootkube"}},
KeyUsages: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
Validity: ValidityTenYears,
IsCA: true,
}
return a.CertKey.Generate(cfg, aggregatorCA, "cluster-apiserver-ca", AppendParent)
}
// Name returns the human-friendly name of the asset.
func (a *ClusterAPIServerCertKey) Name() string {
return "Certificate (clusterapi.openshift-cluster-api.svc)"
}