From 905a39c8011295ee4b290681f0fda6ca753b7ae3 Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Wed, 10 Apr 2019 21:53:45 -0700 Subject: Add option to start https listener Added support for tls connection for k8splugin. It will load the certificates from its current folder. Any installer needs to just put these files in the same folder as the executable and it will pick them up and start in https mode. Issue-ID: MULTICLOUD-570 Change-Id: I505135daa3933b76023c941e7bee54be65fa791f Signed-off-by: Kiran Kamineni --- src/k8splugin/cmd/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/k8splugin/cmd') diff --git a/src/k8splugin/cmd/main.go b/src/k8splugin/cmd/main.go index e600c0d6..53b6ab17 100644 --- a/src/k8splugin/cmd/main.go +++ b/src/k8splugin/cmd/main.go @@ -24,6 +24,7 @@ import ( "k8splugin/api" utils "k8splugin/internal" + "k8splugin/internal/auth" "github.com/gorilla/handlers" ) @@ -55,5 +56,13 @@ func main() { close(connectionsClose) }() - log.Fatal(httpServer.ListenAndServe()) + tlsConfig, err := auth.GetTLSConfig("ca.cert", "server.cert", "server.key") + if err != nil { + log.Println("Error Getting TLS Configuration. Starting without TLS...") + log.Fatal(httpServer.ListenAndServe()) + } else { + httpServer.TLSConfig = tlsConfig + // empty strings because tlsconfig already has this information + err = httpServer.ListenAndServeTLS("", "") + } } -- cgit 1.2.3-korg