Server Dashboard SSL Support (#2982)

This commit is contained in:
EMRE ÇELİK
2022-06-27 05:08:02 +03:00
committed by GitHub
parent c652b8ef07
commit 218b354f82
5 changed files with 93 additions and 28 deletions

View File

@@ -15,6 +15,7 @@
package server
import (
"crypto/tls"
"net"
"net/http"
"net/http/pprof"
@@ -76,14 +77,21 @@ func (svr *Service) RunDashboardServer(address string) (err error) {
ReadTimeout: httpServerReadTimeout,
WriteTimeout: httpServerWriteTimeout,
}
if address == "" || address == ":" {
address = ":http"
}
ln, err := net.Listen("tcp", address)
if err != nil {
return err
}
if svr.cfg.DashboardTLSMode {
cert, err := tls.LoadX509KeyPair(svr.cfg.DashboardTLSCertFile, svr.cfg.DashboardTLSKeyFile)
if err != nil {
return err
}
tlsCfg := &tls.Config{
Certificates: []tls.Certificate{cert},
}
ln = tls.NewListener(ln, tlsCfg)
}
go server.Serve(ln)
return
}