From bcf53f7efdad0ab3861b40f6b1a50b9810affac5 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 4 Dec 2025 08:54:33 +0100 Subject: [PATCH] renamed to tls instead of keys --- internal/app/wwclient/root.go | 4 ++-- internal/app/wwctl/configure/main.go | 2 +- internal/app/wwctl/configure/root.go | 4 ++-- internal/app/wwctl/configure/{keys => tls}/main.go | 4 ++-- .../app/wwctl/configure/{keys => tls}/main_test.go | 2 +- internal/app/wwctl/configure/{keys => tls}/root.go | 14 +++++++------- internal/pkg/config/buildconfig.go.in | 6 +++--- internal/pkg/config/root_test.go | 10 +++++----- internal/pkg/configure/{keys.go => tls.go} | 4 ++-- internal/pkg/warewulfd/provision.go | 2 +- internal/pkg/warewulfd/server/server.go | 6 +++--- userdocs/server/security.rst | 4 ++-- 12 files changed, 31 insertions(+), 31 deletions(-) rename internal/app/wwctl/configure/{keys => tls}/main.go (98%) rename internal/app/wwctl/configure/{keys => tls}/main_test.go (99%) rename internal/app/wwctl/configure/{keys => tls}/root.go (70%) rename internal/pkg/configure/{keys.go => tls.go} (96%) diff --git a/internal/app/wwclient/root.go b/internal/app/wwclient/root.go index 791de899..5d654f79 100644 --- a/internal/app/wwclient/root.go +++ b/internal/app/wwclient/root.go @@ -117,7 +117,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } tlsConfig := &tls.Config{} - if conf.Warewulf.EnableHttps() { + if conf.Warewulf.EnableTLS() { caCert, err := os.ReadFile("/warewulf/keys/warewulf.crt") if err != nil { wwlog.Error("failed to read ca cert: %s", err) @@ -260,7 +260,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { port := conf.Warewulf.Port scheme := "http" - if conf.Warewulf.EnableHttps() { + if conf.Warewulf.EnableTLS() { port = conf.Warewulf.SecurePort scheme = "https" } diff --git a/internal/app/wwctl/configure/main.go b/internal/app/wwctl/configure/main.go index 2db70ec8..5eef8905 100644 --- a/internal/app/wwctl/configure/main.go +++ b/internal/app/wwctl/configure/main.go @@ -28,7 +28,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { certFile := path.Join(keystore, "warewulf.crt") if !util.IsFile(keyFile) || !util.IsFile(certFile) { - err = configure.GenKeys() + err = configure.GenTLSKeys() if err != nil { return err } diff --git a/internal/app/wwctl/configure/root.go b/internal/app/wwctl/configure/root.go index 3649a095..6b4fc5c6 100644 --- a/internal/app/wwctl/configure/root.go +++ b/internal/app/wwctl/configure/root.go @@ -4,10 +4,10 @@ import ( "github.com/spf13/cobra" "github.com/warewulf/warewulf/internal/app/wwctl/configure/dhcp" "github.com/warewulf/warewulf/internal/app/wwctl/configure/hostfile" - "github.com/warewulf/warewulf/internal/app/wwctl/configure/keys" "github.com/warewulf/warewulf/internal/app/wwctl/configure/nfs" "github.com/warewulf/warewulf/internal/app/wwctl/configure/ssh" "github.com/warewulf/warewulf/internal/app/wwctl/configure/tftp" + "github.com/warewulf/warewulf/internal/app/wwctl/configure/tls" "github.com/warewulf/warewulf/internal/app/wwctl/configure/warewulfd" ) @@ -30,7 +30,7 @@ func init() { baseCmd.AddCommand(ssh.GetCommand()) baseCmd.AddCommand(nfs.GetCommand()) baseCmd.AddCommand(hostfile.GetCommand()) - baseCmd.AddCommand(keys.GetCommand()) + baseCmd.AddCommand(tls.GetCommand()) baseCmd.AddCommand(warewulfd.GetCommand()) baseCmd.Flags().BoolVarP(&allFunctions, "all", "a", false, "Configure all services") diff --git a/internal/app/wwctl/configure/keys/main.go b/internal/app/wwctl/configure/tls/main.go similarity index 98% rename from internal/app/wwctl/configure/keys/main.go rename to internal/app/wwctl/configure/tls/main.go index 78144783..b9cdfea7 100644 --- a/internal/app/wwctl/configure/keys/main.go +++ b/internal/app/wwctl/configure/tls/main.go @@ -1,4 +1,4 @@ -package keys +package tls import ( "crypto/x509" @@ -75,7 +75,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } } else { if create { - if err := configure.GenKeys(); err != nil { + if err := configure.GenTLSKeys(); err != nil { return err } if err := configure.WAREWULFD(); err != nil { diff --git a/internal/app/wwctl/configure/keys/main_test.go b/internal/app/wwctl/configure/tls/main_test.go similarity index 99% rename from internal/app/wwctl/configure/keys/main_test.go rename to internal/app/wwctl/configure/tls/main_test.go index ae7d6e85..ae3bb300 100644 --- a/internal/app/wwctl/configure/keys/main_test.go +++ b/internal/app/wwctl/configure/tls/main_test.go @@ -1,4 +1,4 @@ -package keys +package tls import ( "bytes" diff --git a/internal/app/wwctl/configure/keys/root.go b/internal/app/wwctl/configure/tls/root.go similarity index 70% rename from internal/app/wwctl/configure/keys/root.go rename to internal/app/wwctl/configure/tls/root.go index 2614e3e5..0fa24abc 100644 --- a/internal/app/wwctl/configure/keys/root.go +++ b/internal/app/wwctl/configure/tls/root.go @@ -1,4 +1,4 @@ -package keys +package tls import ( "github.com/spf13/cobra" @@ -8,13 +8,13 @@ import ( var ( baseCmd = &cobra.Command{ DisableFlagsInUseLine: true, - Use: "keys [OPTIONS]", + Use: "tls [OPTIONS]", + Aliases: []string{"keys", "key", "cert", "crt"}, Short: "Manage and initialize x509 keys", - Long: "This application allows you to manage the x509 keys for Warewulf\n" + - "based on the configuration in the warewulf.conf file.", - RunE: CobraRunE, - Args: cobra.NoArgs, - ValidArgsFunction: completions.None, + Long: `This application allows you to manage the x509 keys and certificates for Warewulf.`, + RunE: CobraRunE, + Args: cobra.NoArgs, + ValidArgsFunction: completions.None, } importPath string exportPath string diff --git a/internal/pkg/config/buildconfig.go.in b/internal/pkg/config/buildconfig.go.in index 5ce7aad8..d562f5cb 100644 --- a/internal/pkg/config/buildconfig.go.in +++ b/internal/pkg/config/buildconfig.go.in @@ -44,7 +44,7 @@ type WarewulfConf struct { Port int `yaml:"port,omitempty" default:"9873"` SecurePort int `yaml:"secure port,omitempty" default:"9874"` SecureP *bool `yaml:"secure,omitempty" default:"true"` - EnableHttpsP *bool `yaml:"enable https,omitempty" default:"false"` + EnableTLSP *bool `yaml:"tls,omitempty" default:"false"` UpdateInterval int `yaml:"update interval,omitempty" default:"60"` AutobuildOverlaysP *bool `yaml:"autobuild overlays,omitempty" default:"true"` EnableHostOverlayP *bool `yaml:"host overlay,omitempty" default:"true"` @@ -56,8 +56,8 @@ func (conf WarewulfConf) Secure() bool { return util.BoolP(conf.SecureP) } -func (conf WarewulfConf) EnableHttps() bool { - return util.BoolP(conf.EnableHttpsP) +func (conf WarewulfConf) EnableTLS() bool { + return util.BoolP(conf.EnableTLSP) } func (conf WarewulfConf) AutobuildOverlays() bool { diff --git a/internal/pkg/config/root_test.go b/internal/pkg/config/root_test.go index 5f49f253..fe5a6f41 100644 --- a/internal/pkg/config/root_test.go +++ b/internal/pkg/config/root_test.go @@ -17,7 +17,7 @@ func TestParse(t *testing.T) { result: ` warewulf: autobuild overlays: true - enable https: false + tls: false grubboot: false host overlay: true port: 9873 @@ -65,7 +65,7 @@ network: 192.168.0.0 netmask: 255.255.255.0 warewulf: autobuild overlays: true - enable https: false + tls: false grubboot: false host overlay: true port: 9873 @@ -115,7 +115,7 @@ network: 192.168.0.0 netmask: 255.255.0.0 warewulf: autobuild overlays: true - enable https: false + tls: false grubboot: false host overlay: true port: 9873 @@ -162,7 +162,7 @@ ipaddr6: "2001:db8::1" prefixlen6: "64" warewulf: autobuild overlays: true - enable https: false + tls: false grubboot: false host overlay: true port: 9873 @@ -238,7 +238,7 @@ netmask: 255.255.255.0 network: 192.168.200.0 warewulf: autobuild overlays: true - enable https: false + tls: false grubboot: false host overlay: true port: 9873 diff --git a/internal/pkg/configure/keys.go b/internal/pkg/configure/tls.go similarity index 96% rename from internal/pkg/configure/keys.go rename to internal/pkg/configure/tls.go index c54b55ea..1e753482 100644 --- a/internal/pkg/configure/keys.go +++ b/internal/pkg/configure/tls.go @@ -18,9 +18,9 @@ import ( ) /* -GenKeys checks for existence of x509 keys and creates them if they don't exist. +GenTLSKeys checks for existence of x509 keys and creates them if they don't exist. */ -func GenKeys() error { +func GenTLSKeys() error { conf := warewulfconf.Get() keystore := path.Join(conf.Paths.Sysconfdir, "warewulf", "keys") diff --git a/internal/pkg/warewulfd/provision.go b/internal/pkg/warewulfd/provision.go index dffc4699..0bd4888b 100644 --- a/internal/pkg/warewulfd/provision.go +++ b/internal/pkg/warewulfd/provision.go @@ -248,7 +248,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) { Ipaddr: conf.Ipaddr, Ipaddr6: ipaddr6, Port: strconv.Itoa(conf.Warewulf.Port), - Https: conf.Warewulf.EnableHttps(), + Https: conf.Warewulf.EnableTLS(), Authority: authority, Hostname: remoteNode.Id(), Hwaddr: rinfo.hwaddr, diff --git a/internal/pkg/warewulfd/server/server.go b/internal/pkg/warewulfd/server/server.go index baf28bb2..e9153cda 100644 --- a/internal/pkg/warewulfd/server/server.go +++ b/internal/pkg/warewulfd/server/server.go @@ -86,14 +86,14 @@ func RunServer() error { apiHandler = api.Handler(auth, conf.API.AllowedIPNets()) } - httpHandler := configureHandler(!conf.Warewulf.EnableHttps(), apiHandler) + httpHandler := configureHandler(!conf.Warewulf.EnableTLS(), apiHandler) - if conf.Warewulf.EnableHttps() { + if conf.Warewulf.EnableTLS() { key := path.Join(conf.Paths.Sysconfdir, "warewulf", "keys", "warewulf.key") crt := path.Join(conf.Paths.Sysconfdir, "warewulf", "keys", "warewulf.crt") if !util.IsFile(key) || !util.IsFile(crt) { - wwlog.Error("HTTPS enabled but keys not found in %s", path.Join(conf.Paths.Sysconfdir, "warewulf", "keys")) + wwlog.Error("TLS enabled but keys not found in %s", path.Join(conf.Paths.Sysconfdir, "warewulf", "keys")) } else { httpsHandler := configureHandler(true, apiHandler) go func() { diff --git a/userdocs/server/security.rst b/userdocs/server/security.rst index c8141764..139b0388 100644 --- a/userdocs/server/security.rst +++ b/userdocs/server/security.rst @@ -96,8 +96,8 @@ The https functionality can be enabled by setting .. code-block:: yaml .. .. warewulf: -.. enable https: true -.. secure port: 9874 +.. tls: true +.. secure port: 9874 .. Which will enable a https server on the secure port. The certificate and key