diff --git a/internal/startup_manager/startup_manager.go b/internal/startup_manager/startup_manager.go index 7dcb10c..c5e683b 100644 --- a/internal/startup_manager/startup_manager.go +++ b/internal/startup_manager/startup_manager.go @@ -26,6 +26,7 @@ var ( // AppServer defines the behavior of an application server type AppServer interface { ListenAndServe() error + ListenAndServeTLS(certFile, keyFile string) error Shutdown(ctx context.Context) error } @@ -176,7 +177,13 @@ func (sm *StartupManager) startServer(cfg *config.Config) { go func() { slog.Info("starting server", "host", cfg.Server.Host, "port", cfg.Server.Port) - err := appServer.ListenAndServe() + var err error + if cfg.Server.EnableSSL { + err = appServer.ListenAndServeTLS(cfg.Server.CertFile, cfg.Server.KeyFile) + } else { + err = appServer.ListenAndServe() + } + sm.serverErrorChan <- err }() } diff --git a/pkg/config/exporter_config.go b/pkg/config/exporter_config.go index 2a7d78e..9d10af3 100644 --- a/pkg/config/exporter_config.go +++ b/pkg/config/exporter_config.go @@ -48,8 +48,11 @@ type ServerConfig struct { // with the default windows firewall configuration. // Alternatively you can change the firewall configuration to allow // connections to the port from all interfaces. - Host string `yaml:"host"` - Port int `yaml:"port"` + Host string `yaml:"host"` + Port int `yaml:"port"` + CertFile string `yaml:"certFile"` + KeyFile string `yaml:"keyFile"` + EnableSSL bool `yaml:"enableSSL"` } // LoggingConfig represents the logging configuration