From 15e11931fcd85128cada95daba8b72b789d34a97 Mon Sep 17 00:00:00 2001 From: "Mr. Myy" <1135038815@qq.com> Date: Thu, 30 Jul 2020 10:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=20BConfig.Listen.Cl?= =?UTF-8?q?ientAuth=20=E5=AD=97=E6=AE=B5=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=82=E5=BD=93=E6=8C=87=E5=AE=9A=E4=BA=86?= =?UTF-8?q?=E8=AF=A5=E9=85=8D=E7=BD=AE=E6=97=B6=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=9A=84=E5=80=BC=E6=9D=A5=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E3=80=82=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4=E5=80=BC=20tls.Re?= =?UTF-8?q?quireAndVerifyClientCert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app.go b/app.go index f3fe6f7b..5e595bb6 100644 --- a/app.go +++ b/app.go @@ -195,10 +195,15 @@ func (app *App) Run(mws ...MiddleWare) { return } pool.AppendCertsFromPEM(data) - app.Server.TLSConfig = &tls.Config{ + tlsConfig := tls.Config{ ClientCAs: pool, - ClientAuth: tls.RequireAndVerifyClientCert, } + if string(BConfig.Listen.ClientAuth) != "" { + tslConfig.ClientAuth = BConfig.Listen.ClientAuth + } else { + tslConfig.ClientAuth = tls.RequireAndVerifyClientCert + } + app.Server.TLSConfig = &tslConfig } if err := app.Server.ListenAndServeTLS(BConfig.Listen.HTTPSCertFile, BConfig.Listen.HTTPSKeyFile); err != nil { logs.Critical("ListenAndServeTLS: ", err)