From 4382eaf421fe6bf5d7d83dd8e5757fb62c4cda9c Mon Sep 17 00:00:00 2001 From: makeworld Date: Fri, 3 Jul 2020 20:32:37 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Expiry=20date=20is=20stored=20wh?= =?UTF-8?q?en=20cert=20IDs=20match=20-=20fixes=20#39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + client/tofu.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce4222..33cb96b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Link and heading lines are wrapped just like regular text lines - Wrapped list items are indented to stay behind the bullet (#35) +- Certificate expiry date is stored when the cert IDs match (#39) ### Changed - Pages are rewrapped dynamically, whenever the terminal size changes (#33) diff --git a/client/tofu.go b/client/tofu.go index d930717..c4f9ba4 100644 --- a/client/tofu.go +++ b/client/tofu.go @@ -85,13 +85,13 @@ func handleTofu(domain, port string, cert *x509.Certificate) bool { saveTofuEntry(domain, port, cert) return true } - if time.Now().After(expiry) { - // Old cert expired, so anything is valid - saveTofuEntry(domain, port, cert) - return true - } if certID(cert) == id { // Same cert as the one stored + + // Store expiry again in case it changed + tofuStore.Set(expiryKey(domain, port), cert.NotAfter.UTC()) + tofuStore.WriteConfig() + return true } if origCertID(cert) == id { @@ -99,6 +99,11 @@ func handleTofu(domain, port string, cert *x509.Certificate) bool { saveTofuEntry(domain, port, cert) return true } + if time.Now().After(expiry) { + // Old cert expired, so anything is valid + saveTofuEntry(domain, port, cert) + return true + } return false }