Skip to content

Commit 564ec48

Browse files
committed
crypto/tls: don't use CN in BuildNameToCertificate if SANs are present
Change-Id: I18d5b9fc392a6a52fbdd240254d6d9db838073a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/266540 Trust: Filippo Valsorda <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Katie Hockman <[email protected]>
1 parent feccfb8 commit 564ec48

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/crypto/tls/common.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,9 @@ func (c *Config) BuildNameToCertificate() {
12631263
if err != nil {
12641264
continue
12651265
}
1266-
if len(x509Cert.Subject.CommonName) > 0 {
1266+
// If SANs are *not* present, some clients will consider the certificate
1267+
// valid for the name in the Common Name.
1268+
if x509Cert.Subject.CommonName != "" && len(x509Cert.DNSNames) == 0 {
12671269
c.NameToCertificate[x509Cert.Subject.CommonName] = cert
12681270
}
12691271
for _, san := range x509Cert.DNSNames {

0 commit comments

Comments
 (0)