forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
38 lines (30 loc) · 958 Bytes
/
root.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
package tls
import (
"crypto/x509"
"crypto/x509/pkix"
"github.com/openshift/installer/pkg/asset"
)
// RootCA contains the private key and the cert that's
// self-signed as the root CA.
type RootCA struct {
SelfSignedCertKey
}
var _ asset.WritableAsset = (*RootCA)(nil)
// Dependencies returns the dependency of the root-ca, which is empty.
func (c *RootCA) Dependencies() []asset.Asset {
return []asset.Asset{}
}
// Generate generates the root-ca key and cert pair.
func (c *RootCA) Generate(parents asset.Parents) error {
cfg := &CertCfg{
Subject: pkix.Name{CommonName: "root-ca", OrganizationalUnit: []string{"openshift"}},
KeyUsages: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
Validity: ValidityTenYears,
IsCA: true,
}
return c.SelfSignedCertKey.Generate(cfg, "root-ca")
}
// Name returns the human-friendly name of the asset.
func (c *RootCA) Name() string {
return "Root CA"
}