truncate TLS x509 error

This commit is contained in:
iacore 2024-01-18 16:16:04 +00:00
parent 56fd74c8f4
commit ea645e07b3
Signed by: iacore
GPG key ID: F8C16E5157A63006

View file

@ -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()
}