From ea645e07b335f009bee809abdfe0a0139462ada3 Mon Sep 17 00:00:00 2001 From: iacore Date: Thu, 18 Jan 2024 16:16:04 +0000 Subject: [PATCH] truncate TLS x509 error --- scanner/httpSuccess.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scanner/httpSuccess.go b/scanner/httpSuccess.go index 55850f3..d904d03 100644 --- a/scanner/httpSuccess.go +++ b/scanner/httpSuccess.go @@ -1,6 +1,10 @@ package scanner -import "net/http" +import ( + "errors" + "net/http" + x509 "crypto/x509" +) func CheckHTTP200(ctx Context, url string) (bool, string) { req, err := http.NewRequestWithContext(ctx, "GET", url, nil) @@ -9,6 +13,10 @@ func CheckHTTP200(ctx Context, url string) (bool, string) { } resp, err := http.DefaultClient.Do(req) if err != nil { + var tlsCertErr x509.CertificateInvalidError + if errors.As(err, &tlsCertErr) { + return false, "tls: failed to verify certificate: x509: CertificateInvalidError (details truncated)" + } return false, err.Error() }