Skip to content

Commit df89f2b

Browse files
author
Bryan C. Mills
committed
crypto/x509: skip WSATRY_AGAIN errors when dialing badssl.com subdomains
(Temporarily, until the root cause of the test failure can be diagnosed and fixed properly.) For #52094 Change-Id: Iec69e162159f3f0a93135f742aac97cf82c1d96c Reviewed-on: https://go-review.googlesource.com/c/go/+/397478 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 995a604 commit df89f2b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/crypto/x509/root_windows_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ package x509_test
77
import (
88
"crypto/tls"
99
"crypto/x509"
10+
"errors"
1011
"internal/testenv"
12+
"net"
13+
"strings"
14+
"syscall"
1115
"testing"
1216
"time"
1317
)
@@ -17,10 +21,19 @@ func TestPlatformVerifier(t *testing.T) {
1721
t.Skip()
1822
}
1923

20-
getChain := func(host string) []*x509.Certificate {
24+
getChain := func(t *testing.T, host string) []*x509.Certificate {
2125
t.Helper()
2226
c, err := tls.Dial("tcp", host+":443", &tls.Config{InsecureSkipVerify: true})
2327
if err != nil {
28+
// From https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2,
29+
// matching the error string observed in https://go.dev/issue/52094.
30+
const WSATRY_AGAIN syscall.Errno = 11002
31+
var errDNS *net.DNSError
32+
if strings.HasSuffix(host, ".badssl.com") && errors.As(err, &errDNS) && strings.HasSuffix(errDNS.Err, WSATRY_AGAIN.Error()) {
33+
t.Log(err)
34+
testenv.SkipFlaky(t, 52094)
35+
}
36+
2437
t.Fatalf("tls connection failed: %s", err)
2538
}
2639
return c.ConnectionState().PeerCertificates
@@ -74,7 +87,7 @@ func TestPlatformVerifier(t *testing.T) {
7487

7588
for _, tc := range tests {
7689
t.Run(tc.name, func(t *testing.T) {
77-
chain := getChain(tc.host)
90+
chain := getChain(t, tc.host)
7891
var opts x509.VerifyOptions
7992
if len(chain) > 1 {
8093
opts.Intermediates = x509.NewCertPool()

0 commit comments

Comments
 (0)