|
|
@@ -2,6 +2,7 @@ package api
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "crypto/tls"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
@@ -75,7 +76,32 @@ func (hs *HttpServer) listenAndServeTLS(listenAddr, certfile, keyfile string) er
|
|
|
return fmt.Errorf(`Cannot find SSL key_file at %v`, setting.KeyFile)
|
|
|
}
|
|
|
|
|
|
- return http.ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, hs.macaron)
|
|
|
+ tlsCfg := &tls.Config{
|
|
|
+ MinVersion: tls.VersionTLS12,
|
|
|
+ PreferServerCipherSuites: true,
|
|
|
+ CipherSuites: []uint16{
|
|
|
+ tls.TLS_RSA_WITH_AES_128_CBC_SHA,
|
|
|
+ tls.TLS_RSA_WITH_AES_256_CBC_SHA,
|
|
|
+ tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
|
|
|
+ tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
|
|
|
+ tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
|
|
|
+ tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
|
|
|
+ tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
|
|
|
+ tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
|
|
+ tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
|
|
+ tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
|
|
+ tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
|
|
+ tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ srv := &http.Server{
|
|
|
+ Addr: listenAddr,
|
|
|
+ Handler: hs.macaron,
|
|
|
+ TLSConfig: tlsCfg,
|
|
|
+ TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0),
|
|
|
+ }
|
|
|
+
|
|
|
+ return srv.ListenAndServeTLS(setting.CertFile, setting.KeyFile)
|
|
|
}
|
|
|
|
|
|
func (hs *HttpServer) newMacaron() *macaron.Macaron {
|