bash 5 lines · 1 tab

TLS certificate automation with certbot and strict renewal checks

Kai Nakamura Apr 2026
1 tab
#!/usr/bin/env bash
set -euo pipefail

certbot renew --quiet --deploy-hook "systemctl reload nginx"
openssl x509 -enddate -noout -in /etc/letsencrypt/live/example.com/fullchain.pem
1 file · bash Explain with highlit

Certificate expiry outages are avoidable with boring automation and good alerting. I use automatic renewal, post-renew validation hooks, and external checks that warn well before expiry. TLS is not finished once the first certificate works.


Related snips

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyInsecureTransport",
      "Effect": "Deny",

S3 bucket policy that enforces TLS and blocks public reads

s3 aws tls
by Kai Nakamura 1 tab
go
package deps

import (
  "crypto/tls"
  "crypto/x509"
  "net/http"

mTLS client configuration with custom root CA pool

go security tls
by Leah Thompson 1 tab
javascript
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';

export default [
  js.configs.recommended,

ESLint config that avoids bikeshedding

tooling typescript eslint
by codesnips 3 tabs
nginx
server {
  listen 443 ssl;
  server_name internal-api.example.com;

  ssl_certificate /etc/nginx/tls/server.crt;
  ssl_certificate_key /etc/nginx/tls/server.key;

Mutual TLS between internal services with Nginx

mtls tls nginx
by Kai Nakamura 1 tab
yaml
# Install cert-manager (Helm)
# helm install cert-manager jetstack/cert-manager #   --namespace cert-manager #   --create-namespace #   --set installCRDs=true

---
# ClusterIssuer for Let's Encrypt (staging)
apiVersion: cert-manager.io/v1

SSL/TLS certificates with Lets Encrypt and cert-manager

ssl tls certificates
by Ryan Nakamura 2 tabs
python
import requests

response = requests.get('https://crt.sh/', params={'q': '%.example.com', 'output': 'json'}, timeout=15)
response.raise_for_status()
certs = response.json()
print(certs[:5])

Certificate transparency checks for unexpected certificate issuance

certificate-transparency tls monitoring
by Kai Nakamura 1 tab

Share this code

Here's the card — post it anywhere.

TLS certificate automation with certbot and strict renewal checks — share card
Link copied