Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions https/tls_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("", "")
}