优化代码

This commit is contained in:
刘祥超
2022-03-11 17:21:23 +08:00
parent 79ffda4706
commit 0ece9e0897

View File

@@ -34,22 +34,23 @@ func (this *BaseListener) CountActiveConnections() int {
func (this *BaseListener) buildTLSConfig() *tls.Config {
return &tls.Config{
Certificates: nil,
GetConfigForClient: func(configInfo *tls.ClientHelloInfo) (config *tls.Config, e error) {
ssl, _, err := this.matchSSL(configInfo.ServerName)
GetConfigForClient: func(clientInfo *tls.ClientHelloInfo) (config *tls.Config, e error) {
ssl, _, err := this.matchSSL(clientInfo.ServerName)
if err != nil {
return nil, err
}
return ssl.TLSConfig(), nil
},
GetCertificate: func(certInfo *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
_, cert, err := this.matchSSL(certInfo.ServerName)
GetCertificate: func(clientInfo *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
_, cert, err := this.matchSSL(clientInfo.ServerName)
if err != nil {
return nil, err
}
if cert == nil {
return nil, errors.New("no ssl certs found for '" + certInfo.ServerName + "'")
return nil, errors.New("no ssl certs found for '" + clientInfo.ServerName + "'")
}
return cert, nil
},
}