summaryrefslogtreecommitdiffhomepage
path: root/net/tlsdial
diff options
context:
space:
mode:
authorAndrew Dunham <andrew@du.nham.ca>2025-03-10 16:38:44 -0400
committerAndrew Dunham <andrew@du.nham.ca>2025-03-10 16:38:44 -0400
commit5869f14e748f2b217a82f04e3fbb6cf089bff8e3 (patch)
tree911ad8d93ea41aa0dd54d340db914a28fecbc782 /net/tlsdial
parent69b27d2fcfeaa745de072f96dd6c30f4f085ecd9 (diff)
downloadtailscale-andrew/current-time.tar.xz
tailscale-andrew/current-time.zip
net/{currenttime,tlsdial}: add minimum possible time for TLSandrew/current-time
This adds a new package, net/currenttime, which is a thin wrapper around time.Now. If the value returned by time.Now is before a hard-coded value baked into the binary, that hard-coded value will be returned instead. In the case where the system has a buggy, malfunctioning, or nonexistent RTC, this can improve the likelihood that Tailscale will be able to establish a connection to the control plane (via TLS) and fetch the server certificate. As a future TODO: we should cache this value on-disk between process starts (possibly in the state file?) so that we succeed even if the Tailscale server certificate has already expired from the perspective of the minimum time. Additionally, add a GitHub workflow that bumps the current time to a new value every 14 days, so that the value stays reasonably up-to-date in our repository without introducing impurities into the build process. Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: If63cf28c4f188993894d3de589fd65ad447def6f
Diffstat (limited to 'net/tlsdial')
-rw-r--r--net/tlsdial/tlsdial.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/tlsdial/tlsdial.go b/net/tlsdial/tlsdial.go
index 4d22383ef..832a3e67a 100644
--- a/net/tlsdial/tlsdial.go
+++ b/net/tlsdial/tlsdial.go
@@ -29,6 +29,7 @@ import (
"tailscale.com/health"
"tailscale.com/hostinfo"
"tailscale.com/net/bakedroots"
+ "tailscale.com/net/currenttime"
"tailscale.com/net/tlsdial/blockblame"
)
@@ -144,6 +145,7 @@ func Config(host string, ht *health.Tracker, base *tls.Config) *tls.Config {
opts := x509.VerifyOptions{
DNSName: cs.ServerName,
Intermediates: x509.NewCertPool(),
+ CurrentTime: currenttime.Now(), // helps if the system clock is wrong
}
for _, cert := range cs.PeerCertificates[1:] {
opts.Intermediates.AddCert(cert)