From a4e4258a881c8adfb59624165a251caadf0740bd Mon Sep 17 00:00:00 2001 From: Dustin Hooten Date: Tue, 31 Mar 2020 12:36:06 -0600 Subject: [PATCH] Make TLSConfig constructor public Signed-off-by: Dustin Hooten --- https/tls_config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/https/tls_config.go b/https/tls_config.go index dd473d89c3..6226819164 100644 --- a/https/tls_config.go +++ b/https/tls_config.go @@ -35,7 +35,8 @@ type TLSStruct struct { ClientCAs string `yaml:"clientCAs"` } -func getTLSConfig(configPath string) (*tls.Config, error) { +// GetTLSConfig unmarshals TLS configuration at the given configPath and returns a *tls.Config. +func GetTLSConfig(configPath string) (*tls.Config, error) { content, err := ioutil.ReadFile(configPath) if err != nil { return nil, err @@ -110,14 +111,14 @@ func Listen(server *http.Server, tlsConfigPath string) error { return server.ListenAndServe() } var err error - server.TLSConfig, err = getTLSConfig(tlsConfigPath) + server.TLSConfig, err = GetTLSConfig(tlsConfigPath) if err != nil { return err } // Set the GetConfigForClient method of the HTTPS server so that the config // and certs are reloaded on new connections. server.TLSConfig.GetConfigForClient = func(*tls.ClientHelloInfo) (*tls.Config, error) { - return getTLSConfig(tlsConfigPath) + return GetTLSConfig(tlsConfigPath) } return server.ListenAndServeTLS("", "") }