🐛 Don't rerequest resource when bypassing TOFU

This commit is contained in:
makeworld 2020-06-24 12:06:44 -04:00
parent bd6daa5a3c
commit e8e23c7fe6
2 changed files with 9 additions and 10 deletions

View File

@ -105,11 +105,9 @@ func handleTofu(cert *x509.Certificate, port string) bool {
return false
}
// RemoveTofuEntry invalidates the TOFU entry in the database for the given cert and port.
// This will make any cert for that domain valid.
//
// ResetTofuEntry forces the cert passed to be valid, overwriting any previous TOFU entry.
// The port string can be empty, to indicate port 1965.
func RemoveTofuEntry(cert *x509.Certificate, port string) {
func ResetTofuEntry(cert *x509.Certificate, port string) {
tofuStore.Set(idKey(cert.Subject.CommonName, port), "")
tofuStore.WriteConfig()
}

View File

@ -228,13 +228,14 @@ func handleURL(u string) (string, bool) {
if err == client.ErrTofu {
if Tofu(parsed.Host) {
// They want to continue anyway
client.RemoveTofuEntry(res.Cert, parsed.Port())
return handleURL(u)
client.ResetTofuEntry(res.Cert, parsed.Port())
// Response can be used further down
} else {
// They don't want to continue
// Set the bar back to original URL
bottomBar.SetText(tabMap[curTab].Url)
return "", false
}
// They don't want to continue
// Set the bar back to original URL
bottomBar.SetText(tabMap[curTab].Url)
return "", false
} else if err != nil {
Error("URL Fetch Error", err.Error())
// Set the bar back to original URL