Skip to content

Commit 4957dbc

Browse files
committed
sub/play: show detailed errors about TLS certificates
This is helful for debugging proxy issues while writing tests using proxies such as Google httpreplay.
1 parent 15f227e commit 4957dbc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sub/play/play.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"encoding/json"
8+
"errors"
89
"fmt"
910
"io"
1011
"log"
@@ -53,6 +54,11 @@ func main() {
5354
code, _ := io.ReadAll(os.Stdin)
5455
resp, err := http.PostForm("https://play.golang.org/compile", url.Values{"body": {string(code)}})
5556
if err != nil {
57+
if cverr := new(tls.CertificateVerificationError); errors.As(err, &cverr) {
58+
for _, crt := range cverr.UnverifiedCertificates {
59+
log.Printf("Subject: %q, Issuer: %q", crt.Subject, crt.Issuer)
60+
}
61+
}
5662
log.Fatal(err)
5763
}
5864
defer resp.Body.Close()

0 commit comments

Comments
 (0)