Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion installer/pkg/config-generator/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func generateCACert(clusterDir string,
}

// create a CA cert
cfg := &tls.CertCfg{KeyUsages: keyUsages}
cfg := &tls.CertCfg{KeyUsages: keyUsages, IsCA: true}
_, err = generateSignedCert(cfg, csr, key, caKey, caCert, clusterDir, certPath)
if err != nil {
return fmt.Errorf("failed to create a certificate: %v", err)
Expand All @@ -176,6 +176,7 @@ func generateRootCA(path string, key *rsa.PrivateKey) (*x509.Certificate, error)
OrganizationalUnit: []string{"openshift"},
},
KeyUsages: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
IsCA: true,
}
cert, err := tls.SelfSignedCACert(cfg, key)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions installer/pkg/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CertCfg struct {
KeyUsages x509.KeyUsage
Subject pkix.Name
Validity time.Duration
IsCA bool
}

// PrivateKey generates an RSA Private key and returns the value
Expand All @@ -40,7 +41,7 @@ func PrivateKey() (*rsa.PrivateKey, error) {
func SelfSignedCACert(cfg *CertCfg, key *rsa.PrivateKey) (*x509.Certificate, error) {
cert := x509.Certificate{
BasicConstraintsValid: true,
IsCA: true,
IsCA: cfg.IsCA,
KeyUsage: cfg.KeyUsages,
NotAfter: time.Now().Add(cfg.Validity),
NotBefore: time.Now(),
Expand Down Expand Up @@ -81,7 +82,7 @@ func SignedCertificate(
NotBefore: caCert.NotBefore,
SerialNumber: serial,
Subject: csr.Subject,
IsCA: true,
IsCA: cfg.IsCA,
}

certBytes, err := x509.CreateCertificate(rand.Reader, &certTmpl, caCert, key.Public(), caKey)
Expand Down
2 changes: 2 additions & 0 deletions installer/pkg/tls/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestSelfSignedCACert(t *testing.T) {
CommonName: "root_ca",
OrganizationalUnit: []string{"openshift"},
},
IsCA: true,
},
err: false,
},
Expand All @@ -34,6 +35,7 @@ func TestSelfSignedCACert(t *testing.T) {
Subject: pkix.Name{
CommonName: "root_ca",
},
IsCA: false,
},
err: true,
},
Expand Down