mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Enable serve over HTTPS (#263)
This commit is contained in:
parent
352c3cf004
commit
0a1ca0c4fb
2 changed files with 21 additions and 2 deletions
14
cli/serve.go
14
cli/serve.go
|
|
@ -156,8 +156,18 @@ the way that the kolide server works.
|
|||
|
||||
errs := make(chan error, 2)
|
||||
go func() {
|
||||
logger.Log("transport", "http", "address", *httpAddr, "msg", "listening")
|
||||
errs <- http.ListenAndServe(*httpAddr, nil)
|
||||
if !config.Server.TLS || (devMode && !configManager.IsSet("server.tls")) {
|
||||
logger.Log("transport", "http", "address", *httpAddr, "msg", "listening")
|
||||
errs <- http.ListenAndServe(*httpAddr, nil)
|
||||
} else {
|
||||
logger.Log("transport", "https", "address", *httpAddr, "msg", "listening")
|
||||
errs <- http.ListenAndServeTLS(
|
||||
*httpAddr,
|
||||
config.Server.Cert,
|
||||
config.Server.Key,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
c := make(chan os.Signal)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ type ServerConfig struct {
|
|||
Address string
|
||||
Cert string
|
||||
Key string
|
||||
TLS bool
|
||||
}
|
||||
|
||||
// AuthConfig defines configs related to user authorization
|
||||
|
|
@ -101,6 +102,7 @@ func (man Manager) addConfigs() {
|
|||
man.addConfigString("server.address", "0.0.0.0:8080")
|
||||
man.addConfigString("server.cert", "./tools/osquery/kolide.crt")
|
||||
man.addConfigString("server.key", "./tools/osquery/kolide.key")
|
||||
man.addConfigBool("server.tls", true)
|
||||
|
||||
// Auth
|
||||
man.addConfigString("auth.jwt_key", "CHANGEME")
|
||||
|
|
@ -151,6 +153,7 @@ func (man Manager) LoadConfig() KolideConfig {
|
|||
Address: man.getConfigString("server.address"),
|
||||
Cert: man.getConfigString("server.cert"),
|
||||
Key: man.getConfigString("server.key"),
|
||||
TLS: man.getConfigBool("server.tls"),
|
||||
},
|
||||
Auth: AuthConfig{
|
||||
JwtKey: man.getConfigString("auth.jwt_key"),
|
||||
|
|
@ -187,6 +190,12 @@ func (man Manager) LoadConfig() KolideConfig {
|
|||
}
|
||||
}
|
||||
|
||||
// IsSet determines whether a given config key has been explicitly set by any
|
||||
// of the configuration sources. If false, the default value is being used.
|
||||
func (man Manager) IsSet(key string) bool {
|
||||
return man.viper.IsSet(key)
|
||||
}
|
||||
|
||||
// envNameFromConfigKey converts a config key into the corresponding
|
||||
// environment variable name
|
||||
func envNameFromConfigKey(key string) string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue