renamed to tls instead of keys
This commit is contained in:
committed by
Jonathon Anderson
parent
c4b8595f20
commit
bcf53f7efd
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 {
|
||||
@@ -1,4 +1,4 @@
|
||||
package keys
|
||||
package tls
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user