summaryrefslogtreecommitdiff
path: root/tls.go
diff options
context:
space:
mode:
Diffstat (limited to 'tls.go')
-rw-r--r--tls.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/tls.go b/tls.go
index fa25441..d4452f2 100644
--- a/tls.go
+++ b/tls.go
@@ -8,7 +8,7 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/hex"
- "errors"
+ "fmt"
"math/big"
"os"
"time"
@@ -23,7 +23,15 @@ func tlsConfig(state *BrowserState) *tls.Config {
var tofuStore map[string]string
-var ErrTOFUViolation = errors.New("certificate for this domain has changed")
+type TOFUViolation struct {
+ domain string
+ expected string
+ got string
+}
+
+func (tv *TOFUViolation) Error() string {
+ return fmt.Sprintf("certificate for domain %s has changed from %s to %s", tv.domain, tv.expected, tv.got)
+}
var anonymousTLS = &tls.Config{
InsecureSkipVerify: true,
@@ -43,7 +51,11 @@ func tofuVerify(connState tls.ConnectionState) error {
}
if certhash != expected {
- return ErrTOFUViolation
+ return &TOFUViolation{
+ domain: connState.ServerName,
+ expected: expected,
+ got: certhash,
+ }
}
return nil
}