this post was submitted on 06 Oct 2024
50 points (98.1% liked)

Selfhosted

40173 readers
693 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

How do you manage the distribution of internal TLS network certificates? I'm using cert-manager to generate them, but the root self-signed certificate expires monthly which makes distribution to devices outside of K8s a challenge. It's a PITA to keep doing this for the tablet, laptop and phones. I can bump the root cert to a year, but I'm concerned that the date will sneak up on me. Are there any automated solutions?

top 22 comments
sorted by: hot top controversial new old
[–] [email protected] 13 points 1 month ago* (last edited 1 month ago)

Some of my internal stuff goes out to Let's Encrypt, so I don't worry about it at all. My internal AD stuff is set for like three years. If anyone has compromised the CA, they're already past where issuing malicious certs would be useful.

I would up your root cert expiration. You can keep the root CA offline if you're concerned about compromise.

There are also ways to run LE-style automatic renewals internally, but I've never bothered because what I've described above means I don't need it.

[–] [email protected] 10 points 1 month ago (1 children)

Bump root cert to 10 years and use intermediate with shorter lifetime. root cert should be stored and processed off net.

[–] [email protected] 3 points 1 month ago

I think this is what I'm going to do.

[–] [email protected] 7 points 1 month ago (1 children)

For most of my internal services that are sitting behind Traefik I use step-ca which basically gives you a Let's Encrypt style certificate while working over the local network. The root CA has a long expiry (so might not be what you want if your goal Is a short lived root CA) but the actual certificates for each service are short lived (a touch over 24 hours from memory?)

[–] [email protected] 2 points 1 month ago

I tried step-ca to start with, but my primary use case was for certs in the cluster, which cert-manager is more suited for natively. Maybe step-ca has improved, I was using it in the early days. My goal isn't a short lived cert as much as it is to have an easy configuration and to learn.

[–] [email protected] 6 points 1 month ago (1 children)

I looked into this recently.

There's a DNS challenge designed for this exact scenario called (from memory) DNS01, but it's more of a faff than I'm willing to get involved with.

Basically you push proof that you own the domain into a DNS record instead of to a file on a web server. It requires a DNS provider that has an API and a client that speaks that API.

It also leaks private DNS stuff into the public domain.

I'd love it if someone devised an easier way. Maybe there is an easier way?

[–] [email protected] 6 points 1 month ago (2 children)

I do the dns challenge with letsencrypt too but to not leak local dns names into the public I just run a pihole locally that can resolve those domains

[–] [email protected] 3 points 1 month ago* (last edited 1 month ago) (1 children)

The DNS server is only one thing you tell the domain, the other is the certificate authority. And those publish all issued certificates as part of certificate transparency. https://en.m.wikipedia.org/wiki/Certificate_Transparency

To mitigate the amount of published information, you can request wildcard certs to keep the subdomains private.

You can also use a wildcard cname entry to capture all subdomains and leave out the pihole faff, given that you use a reverse proxy that forwards to respective services by subdomain.

[–] [email protected] 1 points 1 month ago

Yep I also run wildcard domains for simplicity

[–] [email protected] 1 points 1 month ago

This is the way.

[–] [email protected] 5 points 1 month ago

Use a secret manager?

Cert is a secret, add a small agent to your containers that pings your secret manager and gets back the current cert. Then saves / imports it (or whatever is appropriate).

[–] [email protected] 5 points 1 month ago* (last edited 1 month ago) (2 children)

MONTHLY?? That's a bit much, don't you think?

If you're regenerating certa that fast, I can't think of anything that's going to secure AND easy enough to satisfy automating this.

Whatever tool you want to use to secure the contents of the cert from its initial creation, to distribution, is fine enough. If you want super easy, use an SSH/SCP script. If you want something more elegant, think Hashicorp Vault or etcd.

Ansible is probably more effort than it's worth (plus securing the secrets of the cert), and any other config mgmt tool won't deal with the distribution portion simply, so I'd skip all of that.

[–] [email protected] 1 points 1 month ago (1 children)

Yes, monthly is too fast. I'm using a K8s operator for cert-manager which defaults to a month. I think I can patch the CSV with an annotation that will bump that out, but when the operator updates the CSV then I need to repatch it.

I was polling the community to see if there's something that is easy to use but I was not able to find in my searches. It seems like a common problem.

Part of my problem is that I chose to use a K8s operator for cert-manager which isn't easy to configure. Had I used a helm chart, i'd have bumped the root cert to 10 years and forgotten about it.

[–] [email protected] 2 points 1 month ago (1 children)

If the operator doesn't allow it for some reason, uninstall it and try with the helm chart instead?

Or is there a reason to use the operator?

[–] [email protected] 1 points 1 month ago

I think it may support it, but it's not well documented. I'll need to read up a bit. I started with helm charts but like how operators, um operate. They upgrade on their own and are very stable. Honestly, though, it was mostly because I wanted to learn how they work.

[–] [email protected] -2 points 1 month ago

Yeah, either secure copy (SCP) or rsync are the ways to do this securely.

[–] [email protected] 3 points 1 month ago (1 children)

DNS challenge with a reverse proxy is that answer. I've been doing this for a while now and it works great. Most other answers here are work arounds or not very robust.

This is the way: https://youtu.be/liV3c9m_OX8

I do this with authentik for sso

I have local only things like vaultwarden and external things like seafile.

[–] [email protected] 1 points 1 month ago (1 children)

I started watching the video. I was not aware that LetsEncrypt supported wildcard certificates. Does this mean that your internal network uses the same domain name as your externally-hosted services?

[–] [email protected] 2 points 1 month ago

Yes.

Vaultwarden.local.example.com

And

Jellyfin.example.com

This is the best and most robust way to do this

[–] [email protected] 2 points 1 month ago

Synching maybe?

[–] [email protected] 2 points 1 month ago (1 children)

Not sure if it'd fit your use case 100%, but this has been a nice middle ground solution for LE certs in my lab: https://www.certwarden.com/

[–] [email protected] 1 points 1 month ago

Hadn't heard of this before. I'll give it a whirl.

Is *warden the new hotness? Bitwarden, vaultwarden, linkwarden and now certwarden?