X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Frestapi%2Fserver.go;h=e4647a2f6946b565c2a80e42b5ed73bb401962a7;hb=c79bd0e1a4fe855b06c8f8131f162d0ee4a5f9f5;hp=23fda83a2fa5210a5aeb54cd933bbbe880eb3a6a;hpb=9ea6c7860300c299b9fe68caaf8aff61b3ec71d2;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/restapi/server.go b/pkg/restapi/server.go index 23fda83..e4647a2 100644 --- a/pkg/restapi/server.go +++ b/pkg/restapi/server.go @@ -133,7 +133,6 @@ func (s *Server) SetAPI(api *operations.XappFrameworkAPI) { } s.api = api - s.api.Logger = log.Printf s.handler = configureAPI(api) } @@ -174,8 +173,6 @@ func (s *Server) Serve() (err error) { go handleInterrupt(once, s) servers := []*http.Server{} - wg.Add(1) - go s.handleShutdown(wg, &servers) if s.hasScheme(schemeUnix) { domainSocket := new(http.Server) @@ -252,7 +249,7 @@ func (s *Server) Serve() (err error) { // https://github.com/golang/go/tree/master/src/crypto/elliptic CurvePreferences: []tls.CurveID{tls.CurveP256}, // Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility - NextProtos: []string{"http/1.1", "h2"}, + NextProtos: []string{"h2", "http/1.1"}, // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols MinVersion: tls.VersionTLS12, // These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy @@ -293,7 +290,7 @@ func (s *Server) Serve() (err error) { // call custom TLS configurator configureTLS(httpsServer.TLSConfig) - if len(httpsServer.TLSConfig.Certificates) == 0 { + if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil { // after standard and custom config are passed, this ends up with no certificate if s.TLSCertificate == "" { if s.TLSCertificateKey == "" { @@ -325,6 +322,9 @@ func (s *Server) Serve() (err error) { }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig)) } + wg.Add(1) + go s.handleShutdown(wg, &servers) + wg.Wait() return nil } @@ -420,6 +420,9 @@ func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout) defer cancel() + // first execute the pre-shutdown hook + s.api.PreServerShutdown() + shutdownChan := make(chan bool) for i := range servers { server := servers[i]