Skip to content

Commit

Permalink
添加对 BConfig.Listen.ClientAuth 字段的逻辑处理。当指定了该配置时,使用配置的值来作为验证客户端的方式。如果没指…
Browse files Browse the repository at this point in the history
…定,使用默认值 tls.RequireAndVerifyClientCert
  • Loading branch information
livelyRyan authored Jul 30, 2020
1 parent 7d56160 commit 15e1193
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 15e1193

Please sign in to comment.