1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 16:10:50 +00:00

Merge pull request #4116 from livelyRyan/patch-2

添加 BConfig.Listen.ClientAuth 字段及处理逻辑
This commit is contained in:
Ming Deng 2020-07-30 16:07:00 +08:00 committed by GitHub
commit 87b40ee9e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

2
app.go
View File

@ -197,7 +197,7 @@ func (app *App) Run(mws ...MiddleWare) {
pool.AppendCertsFromPEM(data)
app.Server.TLSConfig = &tls.Config{
ClientCAs: pool,
ClientAuth: tls.RequireAndVerifyClientCert,
ClientAuth: BConfig.Listen.ClientAuth,
}
}
if err := app.Server.ListenAndServeTLS(BConfig.Listen.HTTPSCertFile, BConfig.Listen.HTTPSKeyFile); err != nil {

View File

@ -21,6 +21,7 @@ import (
"reflect"
"runtime"
"strings"
"crypto/tls"
"github.com/astaxie/beego/config"
"github.com/astaxie/beego/context"
@ -65,6 +66,7 @@ type Listen struct {
HTTPSCertFile string
HTTPSKeyFile string
TrustCaFile string
ClientAuth tls.ClientAuthType
EnableAdmin bool
AdminAddr string
AdminPort int
@ -234,6 +236,7 @@ func newBConfig() *Config {
AdminPort: 8088,
EnableFcgi: false,
EnableStdIo: false,
ClientAuth: tls.RequireAndVerifyClientCert,
},
WebConfig: WebConfig{
AutoRender: true,