Fix reject unknown sni with single cert

This commit is contained in:
hmol233 2021-05-10 00:28:40 +08:00
parent 1f92b948c0
commit e8a8465220
No known key found for this signature in database
GPG key ID: D617A9DAB0C992D5
2 changed files with 4 additions and 4 deletions

View file

@ -214,10 +214,10 @@ func getGetCertificateFunc(c *tls.Config, ca []*Certificate) func(hello *tls.Cli
func getNewGetCertificateFunc(certs []*tls.Certificate, rejectUnknownSNI bool) func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {
return func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {
if len(certs) == 0 {
return nil, newError("empty certs")
return nil, errNoCertificates
}
sni := strings.ToLower(hello.ServerName)
if len(certs) == 1 || sni == "" {
if !rejectUnknownSNI && (len(certs) == 1 || sni == "") {
return certs[0], nil
}
gsni := "*"

View file

@ -215,10 +215,10 @@ func getGetCertificateFunc(c *xtls.Config, ca []*Certificate) func(hello *xtls.C
func getNewGetCertificateFunc(certs []*xtls.Certificate, rejectUnknownSNI bool) func(hello *xtls.ClientHelloInfo) (*xtls.Certificate, error) {
return func(hello *xtls.ClientHelloInfo) (*xtls.Certificate, error) {
if len(certs) == 0 {
return nil, newError("empty certs")
return nil, errNoCertificates
}
sni := strings.ToLower(hello.ServerName)
if len(certs) == 1 || sni == "" {
if !rejectUnknownSNI && (len(certs) == 1 || sni == "") {
return certs[0], nil
}
gsni := "*"