mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-11 20:00:28 +01:00
Doc request: Expected renewal behavior for autocert #628
Closed
opened 2025-12-29 02:21:21 +01:00 by adam
·
7 comments
No Branch/Tag Specified
main
update_flake_lock_action
gh-pages
kradalby/release-v0.27.2
dependabot/go_modules/golang.org/x/crypto-0.45.0
dependabot/go_modules/github.com/opencontainers/runc-1.3.3
copilot/investigate-headscale-issue-2788
copilot/investigate-visibility-issue-2788
copilot/investigate-issue-2833
copilot/debug-issue-2846
copilot/fix-issue-2847
dependabot/go_modules/github.com/go-viper/mapstructure/v2-2.4.0
dependabot/go_modules/github.com/docker/docker-28.3.3incompatible
kradalby/cli-experiement3
doc/0.26.1
doc/0.25.1
doc/0.25.0
doc/0.24.3
doc/0.24.2
doc/0.24.1
doc/0.24.0
kradalby/build-docker-on-pr
topic/docu-versioning
topic/docker-kos
juanfont/fix-crash-node-id
juanfont/better-disclaimer
update-contributors
topic/prettier
revert-1893-add-test-stage-to-docs
add-test-stage-to-docs
remove-node-check-interval
fix-empty-prefix
fix-ephemeral-reusable
bug_report-debuginfo
autogroups
logs-to-stderr
revert-1414-topic/fix_unix_socket
rename-machine-node
port-embedded-derp-tests-v2
port-derp-tests
duplicate-word-linter
update-tailscale-1.36
warn-against-apache
ko-fi-link
more-acl-tests
fix-typo-standalone
parallel-nolint
tparallel-fix
rerouting
ssh-changelog-docs
oidc-cleanup
web-auth-flow-tests
kradalby-gh-runner
fix-proto-lint
remove-funding-links
go-1.19
enable-1.30-in-tests
0.16.x
cosmetic-changes-integration
tmp-fix-integration-docker
fix-integration-docker
configurable-update-interval
show-nodes-online
hs2021
acl-syntax-fixes
ts2021-implementation
fix-spurious-updates
unstable-integration-tests
mandatory-stun
embedded-derp
prtemplate-fix
v0.28.0-beta.1
v0.27.2-rc.1
v0.27.1
v0.27.0
v0.27.0-beta.2
v0.27.0-beta.1
v0.26.1
v0.26.0
v0.26.0-beta.2
v0.26.0-beta.1
v0.25.1
v0.25.0
v0.25.0-beta.2
v0.24.3
v0.25.0-beta.1
v0.24.2
v0.24.1
v0.24.0
v0.24.0-beta.2
v0.24.0-beta.1
v0.23.0
v0.23.0-rc.1
v0.23.0-beta.5
v0.23.0-beta.4
v0.23.0-beta3
v0.23.0-beta2
v0.23.0-beta1
v0.23.0-alpha12
v0.23.0-alpha11
v0.23.0-alpha10
v0.23.0-alpha9
v0.23.0-alpha8
v0.23.0-alpha7
v0.23.0-alpha6
v0.23.0-alpha5
v0.23.0-alpha4
v0.23.0-alpha4-docker-ko-test9
v0.23.0-alpha4-docker-ko-test8
v0.23.0-alpha4-docker-ko-test7
v0.23.0-alpha4-docker-ko-test6
v0.23.0-alpha4-docker-ko-test5
v0.23.0-alpha-docker-release-test-debug2
v0.23.0-alpha-docker-release-test-debug
v0.23.0-alpha4-docker-ko-test4
v0.23.0-alpha4-docker-ko-test3
v0.23.0-alpha4-docker-ko-test2
v0.23.0-alpha4-docker-ko-test
v0.23.0-alpha3
v0.23.0-alpha2
v0.23.0-alpha1
v0.22.3
v0.22.2
v0.23.0-alpha-docker-release-test
v0.22.1
v0.22.0
v0.22.0-alpha3
v0.22.0-alpha2
v0.22.0-alpha1
v0.22.0-nfpmtest
v0.21.0
v0.20.0
v0.19.0
v0.19.0-beta2
v0.19.0-beta1
v0.18.0
v0.18.0-beta4
v0.18.0-beta3
v0.18.0-beta2
v0.18.0-beta1
v0.17.1
v0.17.0
v0.17.0-beta5
v0.17.0-beta4
v0.17.0-beta3
v0.17.0-beta2
v0.17.0-beta1
v0.17.0-alpha4
v0.17.0-alpha3
v0.17.0-alpha2
v0.17.0-alpha1
v0.16.4
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.16.0-beta7
v0.16.0-beta6
v0.16.0-beta5
v0.16.0-beta4
v0.16.0-beta3
v0.16.0-beta2
v0.16.0-beta1
v0.15.0
v0.15.0-beta6
v0.15.0-beta5
v0.15.0-beta4
v0.15.0-beta3
v0.15.0-beta2
v0.15.0-beta1
v0.14.0
v0.14.0-beta2
v0.14.0-beta1
v0.13.0
v0.13.0-beta3
v0.13.0-beta2
v0.13.0-beta1
upstream/v0.12.4
v0.12.4
v0.12.3
v0.12.2
v0.12.2-beta1
v0.12.1
v0.12.0-beta2
v0.12.0-beta1
v0.11.0
v0.10.8
v0.10.7
v0.10.6
v0.10.5
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.1
v0.8.0
v0.7.1
v0.7.0
v0.6.1
v0.6.0
v0.5.2
v0.5.1
v0.5.0
v0.4.0
v0.3.6
v0.3.5
v0.3.4
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.2
v0.2.1
v0.2.0
v0.1.1
v0.1.0
Labels
Clear labels
CLI
DERP
DNS
Nix
OIDC
SSH
bug
database
documentation
duplicate
enhancement
faq
good first issue
grants
help wanted
might-come
needs design doc
needs investigation
no-stale-bot
out of scope
performance
policy 📝
pull-request
question
regression
routes
stale
tags
tailscale-feature-gap
well described ❤️
wontfix
Mirrored from GitHub Pull Request
No Label
enhancement
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/headscale#628
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lgrn on GitHub (Feb 8, 2024).
Why
The current documentation regarding built-in TLS certificate auto-renewals isn't completely clear on what to expect, it currently only states:
Description
I think it would be helpful to document some further information on what intervals should be expected here, and what errors should be actioned/ignored. For example:
Also, the meaning or interpretation of some common log lines would be helpful, like:
acme/autocert: missing server name(?)acme/autocert: host "[redacted-external-ip]" not configured in HostWhitelist(?)I understand that there are alternate solutions to cert renewals and that this could be set up separately ("Bring your own certificate"), but that's not the scope for this request.
@ohdearaugustin commented on GitHub (Feb 9, 2024):
As usual PRs, which improve the docs are very welcome.
@lgrn commented on GitHub (Feb 9, 2024):
Answers to the questions are very welcome too, it makes writing docs a bit easier.
@ohdearaugustin commented on GitHub (Feb 9, 2024):
So headscale uses the autocert for the implementation for acme, in this case letsencrypt.
The corresponding code can be found in app.go:
c3257e2146/hscontrol/app.go (L846-L882)As you can see only basic configuration is passed to the library. This configuration doesn't give an any clue about the renewal time.
I guess as you know letsencrypt certificates are normally valid for 3 month (approx. 90 days). This lead us to take a look at the library itself:
https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.19.0:acme/autocert/autocert.go;drc=4ba4fb4dd9e7f7ed9053fb45482e9a725c7e3fb4;l=134-139
As we can see in the code snippet from headscale, we do not explicitly set
RenewBeforetherefore we will get the default value of720 * time.HourFound here: https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.19.0:acme/autocert/autocert.go;drc=4ba4fb4dd9e7f7ed9053fb45482e9a725c7e3fb4;l=1034
This should answer the first part.
@ohdearaugustin commented on GitHub (Feb 9, 2024):
This could mean no hostname for the certificate is set so probablytls_letsencrypt_hostnameis not set in your config.Edit: The library gives also this error message when you directly curl the IP of your headscale server and not the fqdn. As the letsencrypt certificate does not include the ip.
This answer can be found here.
I just assume now that you got both error messages at the same time, which mean your tls_letsencrypt_hostname is not valid.Edit: This can also mean that someone tries to resolve a different fqdn to your server.
Saw this errors today also on my server. Pretty useless error messages from the library to be honest.
@ohdearaugustin commented on GitHub (Feb 9, 2024):
This question is harder to answer because you have to take a even deeper dive into the code. The corresponding code can be found here.
As far as I understand it the
renewJitteris set to 1h. On a failed renewal of the certificate this is split to 30mins + a random time duration between 0 and 30mins. So your min retry attempt is 30mins after the first or max 60min after the first. And probably after some time you will run into the rate limits of letsencrypt.It seems like that there is no log written for successful renewal of the certificate. Rather the library only gives out errors on specific occasions like:
acme/autocert: invalid new order status %q; order URL: %q"oracme/autocert: invalid account key found in cachefor more possible error message look at the autocertSo if the challenge worked it should have created the certificate and be serving it. The easiest way to check if the worked is to check the certificate in the browser or with
openssl x509 -in <FQDN> -noout -textin the cache folder of headscale.@lgrn commented on GitHub (Feb 10, 2024):
I've created a draft PR here, feel free to have a look when you have the time: https://github.com/juanfont/headscale/pull/1733
Both feedback and direct commits are welcome, I'm under no illusions that it's perfect as-is.
@TotoTheDragon commented on GitHub (Feb 20, 2024):
@kradalby this has been merged, issue can be closed