Merge pull request #301 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:feature/qj-enable-http-tls to release/2.2.0

* commit '575ea95525aea075b1ae8b542151185ee4ba14c5':
  改进:允许climc指定tls证书,允许服务指定tls证书
This commit is contained in:
邱剑
2018-10-18 16:01:19 +08:00
9 changed files with 159 additions and 17 deletions
+10 -2
View File
@@ -22,6 +22,14 @@ func InitApp(options *Options) *appsrv.Application {
func ServeForever(app *appsrv.Application, options *Options) {
addr := net.JoinHostPort(options.Address, strconv.Itoa(options.Port))
log.Infof("Start listen on %s", addr)
app.ListenAndServe(addr)
proto := "http"
if options.EnableSsl {
proto = "https"
}
log.Infof("Start listen on %s://%s", proto, addr)
if options.EnableSsl {
app.ListenAndServeTLS(addr, options.SslCertfile, options.SslKeyfile)
} else {
app.ListenAndServe(addr)
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ func InitAuth(options *Options, authComplete auth.AuthCompletedCallback) {
// debug := options.LogLevel == "debug"
auth.Init(a, false, true) // , authComplete)
auth.Init(a, false, true, options.SslCertfile, options.SslKeyfile) // , authComplete)
authComplete()
}
+4
View File
@@ -36,6 +36,10 @@ type Options struct {
GlobalVirtualResourceNamespace bool `help:"Per project namespace or global namespace for virtual resources"`
DebugSqlchemy bool `default:"False" help:"Print SQL executed by sqlchemy"`
EnableSsl bool `help:"Enable https"`
SslCertfile string `help:"ssl certification file"`
SslKeyfile string `help:"ssl certification key file"`
structarg.BaseOptions
}