Skip to content

Commit 83a71d2

Browse files
committed
Provide custom error message for invalid certificate
This should address part of #7 Also replace deprecated `io/ioutil` by `os`
1 parent fdc3c0f commit 83a71d2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

domains/domains.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"crypto/tls"
55
"crypto/x509/pkix"
66
"fmt"
7-
"io/ioutil"
87
"math/big"
98
"net"
9+
"os"
1010
"sort"
1111
"strings"
1212
"time"
@@ -39,6 +39,8 @@ func (i Response) KnownError() string {
3939
return "certificate SAN don't include domain"
4040
case strings.HasSuffix(i.Error.Error(), "no such host"):
4141
return "no DNS entry for this host"
42+
case strings.HasPrefix(i.Error.Error(), "tls: failed to verify certificate: x509: certificate is valid for"):
43+
return "invalid certificate"
4244
default:
4345
return i.Error.Error()
4446
}
@@ -170,7 +172,7 @@ func CreateReport(domains []Response, queries []string, fileName string, stdOut
170172
if stdOut {
171173
fmt.Print(file.String())
172174
} else {
173-
err := ioutil.WriteFile(fileName, []byte(file.String()), 0644)
175+
err := os.WriteFile(fileName, []byte(file.String()), 0644)
174176
if err != nil {
175177
panic(err)
176178
}

0 commit comments

Comments
 (0)