Everything Is Awesome Until Your Certificate Expires

How an €89 Sectigo wildcard certificate turned into a homelab engineering adventure. From LEGO and Let's Encrypt to automated certificate deployment, DNSSEC, DANE and replacing OpenVPN with WireGuard - a story of eliminating manual maintenance, automation and engineering out dependencies.

Everything Is Awesome Until Your Certificate Expires
Photo by plo olq / Unsplash

How saving €89 a year turned into a distributed certificate management platform, a VPN migration, and an unexpected adventure into the depths of DNS.

There is a particular kind of irrationality that comes with running a homelab.

A normal person, presented with an annual invoice for €89, would probably pay it and get on with their life.

A software engineer looks at that invoice, opens a terminal, and thinks:

I can automate that.

Several evenings later, they have a distributed deployment system, a new VPN architecture, multiple Bash scripts, a DNS API integration, and a significantly more sophisticated understanding of public key infrastructure than they ever intended to acquire.

The financial return on investment is questionable. The entertainment value, however, is outstanding.

This is the story of how I stopped paying for my Sectigo wildcard SSL certificate and started playing with LEGO.

Not the Danish kind.

The €89 Problem

For years, I had been paying approximately €89 annually for a Sectigo wildcard certificate covering *.petkovsky.sk.

It worked. Browsers trusted it. My services were happy. Nobody complained.

The problem wasn't really the €89.

The problem was what happened every year when the certificate needed replacing.

My infrastructure had gradually evolved from a relatively innocent Synology NAS into a small collection of interconnected systems:

  • Synology DSM and its reverse proxy
  • Synology MailPlus Server
  • A secondary Synology NAS
  • Proxmox
  • Several Linux hosts running Webmin
  • Pi-hole
  • NGINX
  • A private Docker Registry
  • Numerous containerised applications

Each of these systems had its own interpretation of what installing a certificate meant.

Some wanted a certificate and a private key. Some wanted a combined PEM file. Some wanted the full certificate chain. Some wanted their certificate in a very particular directory that you probably wouldn't discover without reading documentation, inspecting a running process, or experiencing a moderate amount of suffering.

Some needed a reload. Others needed a restart.

And then there was OpenVPN.

We'll get to OpenVPN.

What I had originally considered certificate renewal was actually a recurring infrastructure maintenance exercise performed by a human being with an increasingly unreliable memory.

And, unfortunately, that human being was me.

Let's Encrypt Everything

Let's Encrypt has been around since 2015, fundamentally changing the economics of encryption on the Internet.

Before Let's Encrypt, enabling HTTPS often involved purchasing a certificate, proving that you owned a domain, downloading various files, and attempting to remember the difference between a root certificate and an intermediate certificate.

Let's Encrypt introduced a different proposition: certificates should be free, and the process of obtaining them should be automated.

Which is an excellent idea.

Except that automation is one of those words that conceals an extraordinary amount of complexity.

Obtaining a certificate is one problem.

Getting every application in your infrastructure to actually use it is an entirely different problem.

And making sure that every application continues to use it, indefinitely, without requiring your intervention, is where things start getting interesting.

Enter LEGO

LEGO, or more precisely go-acme/lego, is an ACME client written in Go.

ACME stands for Automatic Certificate Management Environment, which is a wonderfully optimistic name for a protocol that was about to make me reconsider several of my infrastructure decisions.

LEGO supports numerous DNS providers, including Websupport, where my domain and DNS zone are hosted.

That matters because wildcard certificates require DNS-based domain validation.

Rather than exposing an HTTP endpoint to demonstrate ownership of my domain, I can prove that ownership by temporarily publishing a specially constructed DNS TXT record.

Something like:

_acme-challenge.petkovsky.sk

Let's Encrypt queries DNS, verifies the challenge, and issues the certificate.

LEGO subsequently removes the temporary record.

No manual DNS changes. No emails. No browser-based validation. No clicking on a button to confirm that I am, indeed, still the person who owns the domain I owned yesterday.

Beautiful.

Well, almost.

My DNS zone already contained a CAA record restricting wildcard certificate issuance to Sectigo.

In other words, I had previously configured DNS to protect myself against unauthorised certificate issuance.

And now that protection was successfully protecting me against myself.

Adding the appropriate CAA authorisation solved that particular problem:

CAA 0 issuewild "letsencrypt.org"

On the evening of 31 October 2026, LEGO successfully obtained a certificate covering both:

petkovsky.sk
*.petkovsky.sk

The distinction matters. A wildcard certificate doesn't automatically cover the apex domain, nor does it cover arbitrarily deep subdomains.

The first milestone was complete.

I had a free, publicly trusted certificate.

It was sitting in a directory on my NAS.

And absolutely none of the applications that needed it knew it existed.

The Certificate Factory

My primary Synology DS1522+ became the central certificate management controller.

LEGO runs as a Docker container, managed through Portainer, using a pinned container image:

goacme/lego:v5.6.0

Its persistent working directory lives on the NAS:

/volume1/docker/lego/

The Websupport API credentials are provided through mounted secrets rather than being embedded directly in the deployment scripts.

Every twelve hours, LEGO checks whether the certificate needs renewing. With LEGO version 5, certificate issuance and renewal are handled through the same run command.

Checking every twelve hours doesn't mean requesting a new certificate every twelve hours. It means giving the ACME client regular opportunities to renew when appropriate.

The certificate material remains available to the deployment controller independently of the container lifecycle.

Conceptually, the architecture is remarkably simple.

              Let's Encrypt
                    |
                   ACME
                    |
              LEGO Container
                    |
              Websupport API
                    |
            DNS-01 Validation
                    |
           Certificate Storage
                    |
          Deployment Controller
                    |
             All My Services

Of course, the phrase All My Services is doing a frankly unreasonable amount of work in that diagram.

OpenVPN: The Plot Twist

At this point, I discovered a rather entertaining dependency in my infrastructure.

My Synology NAS was also running OpenVPN.

The way my OpenVPN configuration was distributed to clients meant that changing the certificate could require regenerating and redistributing the VPN profiles containing the relevant certificate trust material.

My phone. My tablet. My laptop. Other devices that needed remote access.

Now consider what happens when you combine that dependency with automated certificate renewal.

At some point, while I'm away from home, my infrastructure automatically replaces its certificate.

My VPN client potentially stops trusting the VPN server.

To fix it, I need to obtain an updated VPN profile.

To obtain an updated VPN profile from my internal infrastructure, I need to connect to my VPN.

Which doesn't work.

There is probably a formal computer science term for this.

I prefer to call it a remarkably efficient way of locking yourself out of your own house without physically leaving it.

This isn't an inherent limitation of OpenVPN. A correctly designed OpenVPN PKI with a stable, independently managed trust anchor can accommodate server certificate rotation.

It was a limitation of how my particular deployment was coupled to the certificate lifecycle of my NAS.

And that coupling needed to go.

Changing the Architecture Instead of Automating the Problem

Rather than building another automation mechanism to distribute OpenVPN profiles, I decided to remove the dependency entirely.

I migrated my remote access infrastructure to WireGuard, running directly on my MikroTik hEX S router.

WireGuard uses its own public and private key pairs to authenticate peers. It doesn't depend on the publicly trusted X.509 wildcard certificate used by my web applications.

My HTTPS certificate can expire, renew, change issuer, or disappear entirely without changing the cryptographic identity of my WireGuard peers.

This gave me two independently managed trust systems:

  • Public TLS certificates for applications and Internet-facing services.
  • WireGuard keys for remote network access.

It also moved the VPN endpoint away from the NAS and onto the network gateway, which is a rather more sensible place for it in my environment.

What started as a certificate renewal project had now resulted in a VPN migration.

This is a recurring phenomenon in engineering.

Sometimes the best way to automate a process is to redesign the system so that half of the process no longer needs to exist.

One Certificate, Many Interpretations

The next challenge was deployment.

I didn't want every host in my infrastructure to run its own ACME client, hold DNS API credentials, and independently request wildcard certificates.

Instead, I wanted a single authoritative certificate source and a collection of service-specific deployment adapters.

The resulting scripts were:

deploy-lego-certificate.sh
deploy-lego-fleet.sh
automate-lego-deployment.sh

The first handles Synology DSM.

The second handles the wider infrastructure.

The third orchestrates the deployment process.

The important architectural decision was to separate certificate acquisition from certificate consumption.

LEGO doesn't need to know what Webmin is.

Webmin doesn't need to know how Let's Encrypt works.

Proxmox doesn't need access to my DNS provider's API.

And my Docker Registry certainly doesn't need permission to modify DNS records.

Each component gets precisely the information it needs to perform its job.

The deployment targets

ServiceDeployment strategy
Synology DSMUpdate the existing managed certificate through DSM's internal certificate API
Synology reverse proxyConsume the certificate through DSM service assignments
MailPlus ServerConsume the DSM-managed certificate and verify SMTP and IMAP endpoints
WebminConstruct the required certificate files, deploy remotely and reload the service
Pi-holeUpdate the certificate material used by its web interface
NGINXReplace the certificate and key, validate configuration and reload
ProxmoxInstall the certificate using Proxmox's certificate management mechanism
Docker RegistryReplace the mounted TLS files and restart when necessary
Secondary Synology NASTransfer certificate material securely and perform local installation through a scheduled task

One certificate. Multiple operating systems. Multiple application architectures. Multiple ways of accomplishing essentially the same thing.

If you've ever wondered why enterprise infrastructure management products exist, try deploying a certificate to nine different services.

The Synology Problem

Synology DSM deserves its own chapter in this story.

DSM already has certificate management. It allows administrators to import certificates and assign them to various applications.

Doing this through the graphical interface is straightforward.

Doing it programmatically, while preserving existing service assignments, requires considerably more attention.

I created a dedicated certificate entry in DSM called LEGO.

Rather than creating a new certificate object every time a renewal happens, the deployment script targets that existing certificate.

That means the association between the certificate and the services consuming it can remain intact.

The script validates the incoming certificate, checks that the private key matches, compares fingerprints, creates a backup and imports the replacement when necessary.

The goal is not to have an ever-growing collection of certificates in DSM.

The goal is to have one logical certificate identity whose underlying cryptographic material changes automatically.

There is an important caveat here: the deployment uses DSM's internal API, which is not something I can assume will remain unchanged across every future DSM release.

Congratulations. My automation now has its own compatibility lifecycle.

The Most Important Feature Is Doing Nothing

One of the most important properties of the deployment system is idempotency.

Idempotency is a complicated-looking word for a beautifully simple idea: performing the same operation repeatedly should not cause unnecessary changes.

If my deployment controller runs every hour, but my certificate changes only occasionally, then almost every execution should accomplish absolutely nothing.

No copying files.

No restarting containers.

No reloading web servers.

No interrupting active connections.

Just checking that everything is as it should be.

The deployment logic follows a consistent pattern:

  1. Validate the source certificate and private key.
  2. Check certificate validity and expected domain names.
  3. Determine the current certificate fingerprint.
  4. Inspect the certificate installed on the destination.
  5. Skip the destination if the expected certificate is already installed.
  6. Back up the existing certificate material.
  7. Deploy the replacement.
  8. Reload or restart the service when necessary.
  9. Verify the outcome.
  10. Report success or failure.

The distinction between certificate deployment and certificate reconciliation is significant.

If a server is offline when a certificate is renewed, a one-time deployment hook might miss it entirely.

A recurring reconciliation process can discover that the server is still using an old certificate when it comes back online.

It doesn't need another certificate renewal to correct the problem.

This is the same principle that underpins many modern infrastructure management systems: describe the desired state, observe the actual state, and reconcile the difference.

I've effectively built a small, specialised certificate reconciliation controller.

With Bash.

Because apparently I enjoy living dangerously.

SUCCESS Is Not a Test Result

During testing, my secondary Synology NAS provided a useful reminder of another fundamental engineering principle.

A script attempted to transfer certificate files to the remote system.

The remote operation encountered a permissions error.

Part of the error-handling logic also failed.

And the script reported:

SUCCESS

Which was certainly an interesting interpretation of events.

The implementation had successfully automated the process of lying to me.

That experience reinforced the importance of verifying file hashes, checking remote command exit codes and distinguishing between successful transfer and successful installation.

The secondary NAS uses a local scheduled task to complete its certificate installation, which introduces an asynchronous step.

Consequently:

Certificate transferred

does not mean:

Certificate installed

And neither necessarily means:

Application serving the new certificate

These are three separate states.

They need to be treated as such.

Trust, but Verify with OpenSSL

Copying a certificate to a server proves that you've copied a certificate to a server.

It does not prove that the application is using it.

This is particularly relevant to my mail infrastructure.

MailPlus exposes several services, each of which needs to present the correct certificate:

PortProtocol
25SMTP with STARTTLS
465SMTP over TLS
587SMTP submission with STARTTLS
143IMAP with STARTTLS
993IMAP over TLS

Using OpenSSL, I independently inspected the certificates actually presented by those endpoints.

All five endpoints successfully presented the new Let's Encrypt certificate, with the same expected fingerprint and expiration date.

That was considerably more reassuring than a Bash script printing a green checkmark.

The file on disk represents the intended state.

The certificate presented over a network connection represents the observable state.

If those two disagree, the automation has more work to do.

And Then There's DANE

At this point, a reasonable person would probably have declared victory.

Unfortunately, I also run DNSSEC and DANE for my mail infrastructure.

DANE stands for DNS-based Authentication of Named Entities.

It allows a DNSSEC-protected DNS record to describe the cryptographic identity expected from a TLS service.

For my SMTP server, that means a TLSA record resembling:

_25._tcp.mail.petkovsky.sk.

3 1 1 <SHA-256 hash of the public key>

The three numbers indicate:

  • 3: The association refers to the end-entity certificate.
  • 1: The selected material is the certificate's Subject Public Key Info.
  • 1: The matching method is SHA-256.

This is not the fingerprint of the entire certificate. It is a hash of the public key information contained within it.

Which creates another fascinating dependency.

When my certificate changes but retains the same public key, the existing TLSA association can remain valid.

When the public key changes, however, the TLSA record needs to change as well.

Otherwise, an external mail server performing DANE validation might correctly conclude that my mail server is presenting an unexpected cryptographic identity.

My mail server would be online.

My certificate would be valid.

My DNSSEC configuration would be working.

And some mail delivery attempts could fail precisely because all those security mechanisms were doing their jobs.

Security is wonderful like that.

Automating DNS Too

Since LEGO was already using Websupport's API for DNS validation, extending the automation to manage TLSA records was the logical next step.

I built another script:

update-lego-tlsa.sh

Its intended responsibility is to calculate the public key hash from the certificate and reconcile the relevant TLSA records through Websupport's API v2.

Rather than hardcoding a single SMTP record, it discovers eligible TLSA records in the DNS zone.

Naturally, the scope must be controlled. A TLSA record belonging to an unrelated service with a different certificate must not be overwritten simply because it exists in the same DNS zone.

The automation was successfully tested against a temporary DNS record. I also independently verified that the existing production DANE configuration was valid.

But there's an important distinction between updating DNS and performing a safe cryptographic rollover.

DNS is distributed. Recursive resolvers cache records.

Replacing an old TLSA record with a new one immediately before or after installing a new certificate can create a temporary mismatch for remote systems.

The correct production strategy, when the key changes, is:

  1. Obtain the replacement certificate.
  2. Calculate its new public key hash.
  3. Publish the new TLSA association alongside the existing one.
  4. Wait for the previous DNS TTL to elapse after publication.
  5. Deploy the new certificate.
  6. Verify the externally visible services.
  7. Remove the obsolete TLSA association.

My existing TLSA records use a TTL of 600 seconds, so DNS propagation and cache expiry become explicit dependencies in the deployment workflow.

The API integration is tested. The complete unattended, overlapping TLSA rollover is the remaining step to validate.

Because apparently my certificate deployment system now needs the distributed-systems equivalent of a two-phase commit.

All because of €89.

The Architecture

The complete target architecture now looks something like this:

              LET'S ENCRYPT
                    |
                    | ACME
                    |
         +----------v-----------+
         | LEGO Docker Container|
         | Renewal check / 12h  |
         +----------+-----------+
                    |
          +---------+---------+
          |                   |
          v                   v
   Websupport API      Certificate Store
   DNS-01 Challenge    Certificate + Key
          |                   |
          |                   v
          |          Deployment Controller
          |                   |
          |          Validate / Reconcile
          |                   |
          |     +-------------+-------------+
          |     |             |             |
          |     v             v             v
          |  Synology      Linux Hosts   Proxmox
          |  DSM           Webmin        Registry
          |  MailPlus      Pi-hole       Minilogy
          |  Proxy         NGINX
          |     |             |             |
          |     +-------------+-------------+
          |                   |
          |              Verification
          |                   |
          +------------ TLSA Lifecycle
                              |
                        DNSSEC / DANE


        MikroTik WireGuard VPN
        Independently managed trust
        No dependency on wildcard TLS

Certificate acquisition runs independently from certificate deployment.

The deployment controller checks the desired state against the current state.

Remote access remains independent of public certificate renewal.

DNS-based certificate associations are incorporated into the certificate lifecycle.

And applications are only restarted or reloaded when necessary.

The intention is that I should eventually be able to forget what the expiration date of my certificate is.

Which is, paradoxically, the ultimate objective of a project that has involved thinking about certificate expiration dates far more than I ever have before.

The Security Trade-Off

Centralising certificate management introduces its own risks.

A wildcard certificate's private key is particularly valuable because compromising it can enable impersonation of multiple services covered by that certificate.

Distributing the same private key across several systems increases the potential impact of a compromised host.

The central certificate controller also holds access to the DNS API, making it a particularly sensitive component.

My security strategy therefore relies on protecting that central controller, restricting access to the private keys, using controlled SSH access, keeping DNS credentials off downstream systems, and maintaining recoverable certificate backups.

An alternative architecture would issue separate certificates and keys for individual services.

That would reduce the shared-key blast radius, at the expense of additional certificate lifecycle management.

For my homelab, centralised wildcard deployment is a deliberate compromise between operational simplicity and security isolation.

Automation should make security manageable.

It should not make the risks invisible.

The Economics of a Homelab

Let's revisit the original business case.

Annual Sectigo certificate cost: €89.

Annual Let's Encrypt certificate cost: €0.

Infrastructure used: Already available.

Engineering effort: We don't talk about the engineering effort.

If I were billing myself consultancy rates for this project, I suspect the break-even point would be somewhere in the distant future.

But the €89 was never really the point.

I've eliminated a recurring manual maintenance process. I've decoupled remote access from application certificates. I've created a reusable deployment architecture. I've learned more about ACME, DNSSEC, DANE, certificate rollover, distributed state reconciliation and service-specific TLS implementation.

And I've removed an entire category of predictable operational failures, subject to proving the remaining unattended renewal and DNS rollover scenarios.

The certificate doesn't need to become my problem every year.

It needs to be the infrastructure's problem.

Everything Is Awesome

There's something rather appropriate about the fact that the ACME client is called LEGO.

LEGO bricks are individually simple. They have clearly defined interfaces. You can connect them in countless ways to build something considerably more sophisticated than any individual component.

That's essentially what I've done.

Let's Encrypt issues certificates.

LEGO handles ACME.

Websupport provides DNS automation.

Synology stores and distributes certificate material.

SSH provides remote deployment.

Service adapters understand application-specific requirements.

OpenSSL verifies the results.

WireGuard removes an unnecessary dependency.

DNSSEC and DANE extend cryptographic trust into DNS.

None of these technologies individually solves the entire problem.

But connect them correctly, and something interesting emerges: an infrastructure capable of maintaining its own cryptographic identity.

No annual certificate invoice.

No calendar reminder.

No manually replacing certificates across half a dozen systems.

No regenerating VPN profiles because a web server certificate changed.

Just a collection of components quietly doing what they were designed to do.

At least, that's the goal.

Because somewhere, right now, a software developer is working on an update that will change an API endpoint, rename a configuration parameter, or introduce an exciting new certificate storage format.

And when that happens, I'll probably open a terminal, look at my infrastructure, and think:

I can automate that.


The certificate is free. The curiosity is expensive.