forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcscertkey.go
49 lines (39 loc) · 1.28 KB
/
mcscertkey.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
45
46
47
48
49
package tls
import (
"crypto/x509"
"crypto/x509/pkix"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
)
// MCSCertKey is the asset that generates the MCS key/cert pair.
type MCSCertKey struct {
CertKey
}
var _ asset.Asset = (*MCSCertKey)(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 *MCSCertKey) Dependencies() []asset.Asset {
return []asset.Asset{
&RootCA{},
&installconfig.InstallConfig{},
}
}
// Generate generates the cert/key pair based on its dependencies.
func (a *MCSCertKey) Generate(dependencies asset.Parents) error {
rootCA := &RootCA{}
installConfig := &installconfig.InstallConfig{}
dependencies.Get(rootCA, installConfig)
hostname := apiAddress(installConfig.Config)
cfg := &CertCfg{
Subject: pkix.Name{CommonName: hostname},
ExtKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
Validity: ValidityTenYears,
DNSNames: []string{hostname},
}
return a.CertKey.Generate(cfg, rootCA, "machine-config-server", DoNotAppendParent)
}
// Name returns the human-friendly name of the asset.
func (a *MCSCertKey) Name() string {
return "Certificate (mcs)"
}