From 34617390d05dd8574a21412aeb223218c998f83a Mon Sep 17 00:00:00 2001 From: Bartosz Lenart Date: Tue, 11 Jul 2023 19:24:35 +0200 Subject: [PATCH] Generation of certificates and keys for etcd gated if etcd is disabled. (#6998) Problem: When support for etcd was added in 3957142, generation of certificates and keys for etcd was not gated behind use of managed etcd. Keys are generated and distributed across servers even if managed etcd is not enabled. Solution: Allow generation of certificates and keys only if managed etc is enabled. Check config.DisableETCD flag. Signed-off-by: Bartossh --- pkg/daemons/control/deps/deps.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/daemons/control/deps/deps.go b/pkg/daemons/control/deps/deps.go index f08708b485..385812a24c 100644 --- a/pkg/daemons/control/deps/deps.go +++ b/pkg/daemons/control/deps/deps.go @@ -446,6 +446,7 @@ func genServerCerts(config *config.Control) error { } func genETCDCerts(config *config.Control) error { + runtime := config.Runtime regen, err := createSigningCertKey("etcd-server", runtime.ETCDServerCA, runtime.ETCDServerCAKey) if err != nil { @@ -455,13 +456,6 @@ func genETCDCerts(config *config.Control) error { altNames := &certutil.AltNames{} addSANs(altNames, config.SANs) - if _, err := createClientCertKey(regen, "etcd-server", nil, - altNames, []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, - runtime.ETCDServerCA, runtime.ETCDServerCAKey, - runtime.ServerETCDCert, runtime.ServerETCDKey); err != nil { - return err - } - if _, err := createClientCertKey(regen, "etcd-client", nil, nil, []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, runtime.ETCDServerCA, runtime.ETCDServerCAKey, @@ -481,6 +475,17 @@ func genETCDCerts(config *config.Control) error { return err } + if config.DisableETCD { + return nil + } + + if _, err := createClientCertKey(regen, "etcd-server", nil, + altNames, []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, + runtime.ETCDServerCA, runtime.ETCDServerCAKey, + runtime.ServerETCDCert, runtime.ServerETCDKey); err != nil { + return err + } + return nil }