|
| 1 | +# shimkit tls |
| 2 | + |
| 3 | +TLS certificate lifecycle helper. Container-first: every certbot |
| 4 | +invocation is a one-shot through the upstream `certbot/certbot` |
| 5 | +image. The `/etc/letsencrypt` directory is bind-mounted at |
| 6 | +`~/.shimkit/data/tls/etc-letsencrypt/` so account + cert state |
| 7 | +survives container exits and host reboots. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +| Command | Purpose | |
| 12 | +|---------|---------| |
| 13 | +| `shimkit tls` | Menu. | |
| 14 | +| `shimkit tls request -d D [-d D2 ...] --email E --webroot PATH [--staging]` | MODERATE. Request a new cert via webroot ACME challenge. | |
| 15 | +| `shimkit tls list [--json]` | Enumerate local certs with expiry dates. | |
| 16 | +| `shimkit tls status DOMAIN [--json]` | Show one cert's paths + expiry. | |
| 17 | +| `shimkit tls renew [-d DOMAIN] [--force-renewal]` | MODERATE. Renew certs (all due, or one named). | |
| 18 | +| `shimkit tls revoke -d DOMAIN --confirm REVOKE-TLS` | SEVERE. Revoke a cert via the ACME CA. | |
| 19 | +| `shimkit tls cron-install [--schedule S]` | MODERATE. Install a daily `shimkit tls renew` cron entry. | |
| 20 | + |
| 21 | +Universal flags before the subcommand (`--quiet`, `--verbose`, |
| 22 | +`--log-file`, `--no-color`, `--color`, `--no-input`); per-command |
| 23 | +flags after (`--json`, `--dry-run`, `--yes`, `--force`). |
| 24 | + |
| 25 | +## How it works |
| 26 | + |
| 27 | +`shimkit tls request` runs: |
| 28 | + |
| 29 | +``` |
| 30 | +docker run --rm \ |
| 31 | + -v ~/.shimkit/data/tls/etc-letsencrypt:/etc/letsencrypt \ |
| 32 | + -v ~/.shimkit/data/tls/var-lib-letsencrypt:/var/lib/letsencrypt \ |
| 33 | + -v <webroot>:/webroot:ro \ |
| 34 | + certbot/certbot:v3.0.1 \ |
| 35 | + certonly --non-interactive --agree-tos \ |
| 36 | + --email ops@example.com \ |
| 37 | + --webroot -w /webroot \ |
| 38 | + -d example.com [-d www.example.com] \ |
| 39 | + [--staging] |
| 40 | +``` |
| 41 | + |
| 42 | +The webroot must already be served at |
| 43 | +`http://<domain>/.well-known/acme-challenge/` for the ACME challenge |
| 44 | +to succeed. The recommended layout for `shimkit web nginx vhost`- |
| 45 | +generated vhosts is the project root. |
| 46 | + |
| 47 | +`certbot/certbot:v3.0.1` is the default; override via |
| 48 | +`tools.tls.certbot_image` in your user config. Pinning to a |
| 49 | +specific version rather than `:latest` keeps renewal behaviour |
| 50 | +deterministic. |
| 51 | + |
| 52 | +## On-disk layout |
| 53 | + |
| 54 | +``` |
| 55 | +~/.shimkit/data/tls/ |
| 56 | +├── etc-letsencrypt/ # mounts to /etc/letsencrypt |
| 57 | +│ ├── live/<domain>/ # symlinks (fullchain.pem, privkey.pem, ...) |
| 58 | +│ ├── archive/<domain>/ # numbered cert history |
| 59 | +│ ├── accounts/ # ACME account keys + metadata |
| 60 | +│ └── renewal/ # renewal config per cert |
| 61 | +└── var-lib-letsencrypt/ # mounts to /var/lib/letsencrypt |
| 62 | +``` |
| 63 | + |
| 64 | +Point nginx at `fullchain.pem` + `privkey.pem` from the `live/` |
| 65 | +directory — they're stable symlinks that get repointed each |
| 66 | +renewal, so nginx never needs to be told a new cert path. |
| 67 | + |
| 68 | +## Examples |
| 69 | + |
| 70 | +```bash |
| 71 | +# Request a cert in staging first (recommended — Let's Encrypt |
| 72 | +# rate-limits production aggressively, but staging is forgiving). |
| 73 | +shimkit tls request --yes --staging \ |
| 74 | + --email ops@example.com \ |
| 75 | + --webroot /var/www/example \ |
| 76 | + -d example.com -d www.example.com |
| 77 | + |
| 78 | +# Once staging works, request the real cert. |
| 79 | +shimkit tls request --yes \ |
| 80 | + --email ops@example.com \ |
| 81 | + --webroot /var/www/example \ |
| 82 | + -d example.com -d www.example.com |
| 83 | + |
| 84 | +# Enumerate local certs. |
| 85 | +shimkit tls list |
| 86 | +shimkit tls list --json |
| 87 | + |
| 88 | +# Inspect a single cert. |
| 89 | +shimkit tls status example.com |
| 90 | +shimkit tls status example.com --json |
| 91 | + |
| 92 | +# Renew everything that's within 30 days of expiry. |
| 93 | +shimkit tls renew --yes |
| 94 | + |
| 95 | +# Force a renewal even if the cert isn't due (test, key rotation). |
| 96 | +shimkit tls renew --yes --force-renewal -d example.com |
| 97 | + |
| 98 | +# Install the daily renewal cron entry (default: 03:17 every day). |
| 99 | +shimkit tls cron-install --yes |
| 100 | + |
| 101 | +# Custom schedule. |
| 102 | +shimkit tls cron-install --yes --schedule "0 4 * * *" |
| 103 | + |
| 104 | +# Revoke (SEVERE — confirm token required). |
| 105 | +shimkit tls revoke -d example.com --confirm REVOKE-TLS |
| 106 | +``` |
| 107 | + |
| 108 | +## Configuration |
| 109 | + |
| 110 | +```json |
| 111 | +{ |
| 112 | + "tools": { |
| 113 | + "tls": { |
| 114 | + "data_dir": "~/.shimkit/data/tls", |
| 115 | + "certbot_image": "certbot/certbot:v3.0.1", |
| 116 | + "default_method": "webroot", |
| 117 | + "default_email": null, |
| 118 | + "renewal_schedule": "17 3 * * *", |
| 119 | + "revoke_severe_token": "REVOKE-TLS" |
| 120 | + }, |
| 121 | + "versions": { |
| 122 | + "openssl": {"min": "1.1"} |
| 123 | + } |
| 124 | + } |
| 125 | +} |
| 126 | +``` |
| 127 | + |
| 128 | +`default_email` set in the user config lets you drop `--email` |
| 129 | +from every `shimkit tls request` invocation. `tools.versions.openssl` |
| 130 | +is the floor used by `shimkit doctor` and the cert-expiry parsing |
| 131 | +in `tls list` / `tls status` (which shells out to `openssl x509 |
| 132 | +-enddate`). |
| 133 | + |
| 134 | +## Exit codes |
| 135 | + |
| 136 | +| Code | Meaning | |
| 137 | +|-----:|---------| |
| 138 | +| 0 | success | |
| 139 | +| 1 | invalid input, missing webroot, certbot failed, missing cert, missing severe token | |
| 140 | +| 2 | Typer usage error | |
| 141 | +| 69 | `EX_UNAVAILABLE` — docker missing / daemon unreachable / out-of-range | |
| 142 | +| 130 | SIGINT | |
| 143 | + |
| 144 | +## Platform support |
| 145 | + |
| 146 | +| Platform | Status | |
| 147 | +|----------|--------| |
| 148 | +| macOS | full (Docker Desktop required). | |
| 149 | +| Linux | full. | |
| 150 | +| WSL | full (Docker Desktop or native Docker). | |
| 151 | +| Windows | out of charter — use WSL. | |
| 152 | + |
| 153 | +## Notes |
| 154 | + |
| 155 | +- **Staging first.** Let's Encrypt's production rate limits are |
| 156 | + punishing (5 failed validations / hour / hostname). Always |
| 157 | + pass `--staging` for first runs; the resulting cert isn't |
| 158 | + trusted but proves the webroot setup works. |
| 159 | +- **Webroot vs DNS-01.** Only webroot is wired today. DNS-01 |
| 160 | + (required for wildcard certs) lands as opt-in extras in a |
| 161 | + future release — each provider needs its own credential |
| 162 | + surface (`cloudflare`, `route53`, etc.). |
| 163 | +- **No PyPI extra.** This tool reuses the `[docker-clean]` |
| 164 | + extra's `docker` package — no new install footprint. |
| 165 | +- **Renewal cadence.** Let's Encrypt certs are valid for 90 days; |
| 166 | + certbot's `renew` only renews within 30 days of expiry, so the |
| 167 | + daily cron is safe (and idempotent — no-op when nothing's due). |
0 commit comments