Add Aruba InstantOS certificate update tool and hermes skill
Automates pushing a renewed TLS certificate to an Aruba InstantOS AP and pointing the Web UI certificate usage at it, replacing the manual Maintenance -> Certificates flow. Commands: status, check-caddy, check-ap, update. `update` is idempotent, so it is safe to run on a schedule. The /swarm.cgi API was reverse-engineered from the InstantOS 8.x web UI bundle and verified against live hardware. Four behaviours documented in the README each silently break a naive implementation: - scalars return as <data name=".."> rather than named tags, including the login sid - cert types are ServerCert/TrustedCA/ClientCert/PublicCert; the server_cert values in the bundle are overwritten at runtime - uploads are synchronous and the POST body is the only real result; upload_status returns not_available even for uploads that succeeded - the AP closes TLS without close_notify, which OpenSSL 3 rejects Credentials are read from ~/.config/aruba-ap-cert/.env, outside the repo. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
commit
dd608e6a20
6 files changed
+1423
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# Copy to ~/.config/aruba-ap-cert/.env and fill in. Never commit the real file.
|
||||
# mkdir -p ~/.config/aruba-ap-cert && chmod 700 ~/.config/aruba-ap-cert
|
||||
# cp .env.example ~/.config/aruba-ap-cert/.env
|
||||
# chmod 600 ~/.config/aruba-ap-cert/.env
|
||||
|
||||
# AP portal address -- IP or hostname, with port (InstantOS uses 4343).
|
||||
ARUBA_HOST=10.0.0.2:4343
|
||||
|
||||
# The same login you use for the AP's web portal.
|
||||
ARUBA_USERNAME=admin
|
||||
ARUBA_PASSWORD=
|
||||
|
||||
# Only if the private key file is encrypted.
|
||||
#ARUBA_KEY_PASSPHRASE=
|
||||
@@ -0,0 +1,2 @@
|
||||
* text=auto eol=lf
|
||||
*.py text eol=lf
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
# Credentials -- never commit
|
||||
.env
|
||||
.env.local
|
||||
|
||||
# Private keys and combined bundles (a bundle contains the key)
|
||||
*.key
|
||||
*.pem
|
||||
*.combined.crt
|
||||
wildcard_*
|
||||
|
||||
__pycache__/
|
||||
*.pyc
|
||||
@@ -0,0 +1,200 @@
|
||||
# aruba-cert
|
||||
|
||||
Push a renewed TLS certificate to an Aruba InstantOS AP / Virtual Controller and
|
||||
point the Web UI at it — the scripted version of **Maintenance → Certificates →
|
||||
Upload New Certificate**, followed by **Certificate Usage → +**.
|
||||
|
||||
Built for a setup where Caddy renews a wildcard certificate via Let's Encrypt
|
||||
and the AP needs to be updated by hand afterwards.
|
||||
|
||||
## Requirements
|
||||
|
||||
```bash
|
||||
pip install requests cryptography
|
||||
```
|
||||
|
||||
Python 3.9+. Works with `cryptography` 41 and newer.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
python3 aruba_cert.py status # compare Caddy against the AP
|
||||
python3 aruba_cert.py check-caddy # expiry of the cert in Caddy's store
|
||||
python3 aruba_cert.py check-ap # expiry of the cert live on the AP
|
||||
python3 aruba_cert.py update # combine, upload, re-point the usage
|
||||
```
|
||||
|
||||
`update` is idempotent: if the AP already serves a certificate as new as the
|
||||
source, it reports that and exits 0 without changing anything. `--force`
|
||||
overrides, `--dry-run` previews.
|
||||
|
||||
`check-caddy` needs no credentials.
|
||||
|
||||
## Credential setup
|
||||
|
||||
The script needs the AP's admin login. It is never passed on the command line.
|
||||
|
||||
**1. Create the credential file.** It lives outside the repo so it can never be
|
||||
committed:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.config/aruba-ap-cert && chmod 700 ~/.config/aruba-ap-cert
|
||||
cp .env.example ~/.config/aruba-ap-cert/.env
|
||||
chmod 600 ~/.config/aruba-ap-cert/.env
|
||||
```
|
||||
|
||||
**2. Fill it in** with the same username and password you use to log in to the
|
||||
AP's web portal at `https://<ap-address>:4343`:
|
||||
|
||||
```ini
|
||||
ARUBA_HOST=10.0.0.2:4343
|
||||
ARUBA_USERNAME=admin
|
||||
ARUBA_PASSWORD=your-password
|
||||
```
|
||||
|
||||
`ARUBA_HOST` takes an IP or hostname **with port** — the InstantOS portal
|
||||
normally listens on 4343. These two values are the only things that change
|
||||
between deployments.
|
||||
|
||||
**3. Check it works:**
|
||||
|
||||
```bash
|
||||
python3 aruba_cert.py check-ap
|
||||
```
|
||||
|
||||
A wrong password gives `login failed -- the AP did not return a session id`.
|
||||
|
||||
### Where credentials are read from
|
||||
|
||||
In order, first match wins:
|
||||
|
||||
1. `--password-file <path>`
|
||||
2. `$ARUBA_PASSWORD` — a real environment variable beats the file
|
||||
3. `~/.config/aruba-ap-cert/.env`
|
||||
4. `.env` beside the script, then `./.env`
|
||||
5. an interactive prompt, only if stdin is a terminal
|
||||
|
||||
`--env-file` points somewhere else entirely. If the private key is encrypted,
|
||||
set `ARUBA_KEY_PASSPHRASE` the same way.
|
||||
|
||||
> **Never commit `.env`.** It is gitignored here, but the safest habit is to
|
||||
> keep it in `~/.config/` as above and leave the repo copy as `.env.example`.
|
||||
|
||||
## Where the certificate comes from
|
||||
|
||||
By default, a Caddy ACME storage directory holding `<name>.crt` (leaf + chain)
|
||||
and `<name>.key`:
|
||||
|
||||
```
|
||||
/mnt/lu-nas/docker/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.luci.ooo/
|
||||
```
|
||||
|
||||
Override with `--caddy-dir <dir>`, `$CADDY_CERT_DIR`, or an arbitrary pair via
|
||||
`--cert` / `--key`.
|
||||
|
||||
## What `update` does
|
||||
|
||||
1. Loads the certificate and key, and confirms the key actually matches the
|
||||
certificate — refusing to upload a mismatched pair. Warns if the matching
|
||||
certificate is a CA certificate, which usually means the wrong key.
|
||||
2. Concatenates them as **cert, chain, key**. The private key must come *after*
|
||||
the certificate for InstantOS.
|
||||
3. Skips the upload if the AP already has something this new, unless `--force`.
|
||||
4. Uploads via multipart POST to `/swarm.cgi`, naming the certificate after its
|
||||
expiry in local time — `Sep2_2026` — then confirms it appears in
|
||||
`show cert all`.
|
||||
5. Pushes the certificate usage:
|
||||
|
||||
```
|
||||
wlan cert-assignment-profile
|
||||
pki-cert-assign application ui cert-type ServerCert certname <name>
|
||||
exit
|
||||
```
|
||||
|
||||
6. Prints `show cert assignment`, and deletes the temporary bundle, which
|
||||
contains the private key.
|
||||
|
||||
## Useful flags
|
||||
|
||||
| Flag | Effect |
|
||||
| --- | --- |
|
||||
| `--dry-run` | Build the bundle and print the plan; no AP contact. |
|
||||
| `--force` | Upload even if the AP already has a certificate this new. |
|
||||
| `--no-assign` | Upload only, leave Certificate Usage alone. |
|
||||
| `--application` | Which usage to set. Default `ui`. Also `radius`, `captive-portal`, `radsec`, `datatunnel`, `clearpass`, `webcc`. |
|
||||
| `--upload-type` | Certificate slot: `server` (default), `ca`, `client`, `public`. |
|
||||
| `--cert-name` | Override the expiry-derived name. |
|
||||
| `--replace` | Delete an existing certificate of the same name first. |
|
||||
| `--keep-bundle` | Do not delete the combined bundle afterwards. |
|
||||
| `--verify` | Verify the AP's TLS certificate. Off by default — you are usually replacing the very certificate you would verify against. |
|
||||
|
||||
## Automation
|
||||
|
||||
Safe to run on a schedule, since it exits 0 without side effects when the AP is
|
||||
already current:
|
||||
|
||||
```bash
|
||||
python3 aruba_cert.py update
|
||||
```
|
||||
|
||||
Exit code is `0` on success (including "nothing to do") and `1` on failure.
|
||||
|
||||
## Notes and caveats
|
||||
|
||||
- **The Web UI certificate takes effect when the AP's web server restarts.** If
|
||||
the portal still serves the old certificate after a successful update, reboot
|
||||
the virtual controller.
|
||||
- **`ui` and `captive-portal` are independent usages** pointing at independent
|
||||
certificates. Updating one leaves the other alone.
|
||||
- `--replace` deletes before uploading. If the upload then fails, that
|
||||
certificate is gone from the AP. Prefer letting the expiry-based naming create
|
||||
a new entry instead.
|
||||
- The AP rejects a re-upload of an identical certificate with
|
||||
`Abort because Cert with same digest already exists as <name>`.
|
||||
|
||||
## Protocol reference
|
||||
|
||||
Reverse-engineered from the InstantOS 8.x web UI bundle (`/jscripts/app.js`) and
|
||||
verified against a live AP. All calls go to `/swarm.cgi`; responses are XML
|
||||
rooted at `<re>`, with errors in `<error>`.
|
||||
|
||||
| Operation | Request |
|
||||
| --- | --- |
|
||||
| Login | `opcode=login user=.. passwd=..` |
|
||||
| Show | `opcode=show cmd="show cert all"` |
|
||||
| Config push | `opcode=config cmd="<CLI lines>"` |
|
||||
| Action | `opcode=action cmd="crypto pki-remove ..."` |
|
||||
| Upload | multipart, `opcode=cert-upload-new`, file field `cert`, plus `cert_name`, `cert_type`, `cert_format`, `psk`, `upload_id` |
|
||||
|
||||
Four things about this API are not obvious, and each one silently breaks a
|
||||
straightforward implementation:
|
||||
|
||||
**Scalars are not returned as named tags.** They arrive as
|
||||
`<data name=" Operation State " pn="true">success</data>`, and the UI derives a
|
||||
key by stripping quotes, trimming, collapsing whitespace to `_`, mapping `-` to
|
||||
`_`, and lowercasing — giving `operation_state`. The login `sid` arrives this
|
||||
way too, so looking for a `<sid>` element finds nothing and every login appears
|
||||
to fail. Tables use a separate `<t><th><h>..</h></th><r><c>..</c></r></t>` shape.
|
||||
|
||||
**Certificate types are `ServerCert` / `TrustedCA` / `ClientCert` /
|
||||
`PublicCert`.** The bundle appears to offer `server_cert`, `ca_cert` and friends,
|
||||
but that option list is overwritten at runtime via babel's `_defineProperty`
|
||||
helper. Sending `server_cert` fails with `Cert Path: cert type is unknown`.
|
||||
|
||||
**Uploads are synchronous, and the POST body is the only real result.** The web
|
||||
UI polls `opcode=upload_status&oper_id=..`, but at least this AP answers
|
||||
`not_available` for every id — including uploads that demonstrably succeeded.
|
||||
Trusting that poll reports working uploads as failures. Read the POST body for
|
||||
`<error>`, then confirm via `show cert all`.
|
||||
|
||||
**The AP closes TLS without a `close_notify` alert.** OpenSSL 3 treats that as a
|
||||
truncated response and discards the body, so every request fails with
|
||||
`ChunkedEncodingError`. The client sets `OP_IGNORE_UNEXPECTED_EOF`, which is what
|
||||
curl and the AP's own web UI effectively do.
|
||||
|
||||
A failed login returns `<re></re>` with no `sid`; an expired session returns
|
||||
`<error>Invalid Session ID</error>`.
|
||||
|
||||
`show supported-cert-formats` on this hardware reports **PEM as the only
|
||||
supported server-certificate format**, so a combined PEM bundle is the required
|
||||
upload shape — PKCS#12 is not available for server certificates.
|
||||
@@ -0,0 +1,113 @@
|
||||
---
|
||||
name: aruba-ap-cert
|
||||
description: Check and update the TLS certificate on the Aruba InstantOS AP portal (aruba.luci.ooo:4343) from Caddy's Let's Encrypt store on LU-NAS. Use for checking cert expiry on either side, or pushing a renewed wildcard cert to the AP Web UI.
|
||||
version: 1.0
|
||||
author: hermes
|
||||
tags: [aruba, instantos, tls, certificate, caddy, luci.ooo, letsencrypt]
|
||||
---
|
||||
|
||||
# Aruba AP Certificate Update
|
||||
|
||||
## Overview
|
||||
|
||||
Caddy on LU-NAS renews the `*.luci.ooo` wildcard certificate via Let's Encrypt.
|
||||
The Aruba AP does **not** pick this up automatically — the cert must be combined
|
||||
with its private key and uploaded to the AP portal by hand. This skill automates
|
||||
that.
|
||||
|
||||
Everything is in `aruba_cert.py` next to this file. Run it on **luhpe**, where
|
||||
`/mnt/lu-nas` is mounted.
|
||||
|
||||
## The three operations
|
||||
|
||||
```bash
|
||||
# 1. Expiry of the certificate Caddy has (no credentials needed)
|
||||
python3 aruba_cert.py check-caddy
|
||||
|
||||
# 2. Expiry of the certificate live on the AP Web UI
|
||||
python3 aruba_cert.py check-ap
|
||||
|
||||
# 3. Compare both side by side — start here
|
||||
python3 aruba_cert.py status
|
||||
|
||||
# 4. Push Caddy's certificate to the AP and point the Web UI at it
|
||||
python3 aruba_cert.py update
|
||||
```
|
||||
|
||||
`update` is **idempotent**: if the AP already serves a certificate as new as
|
||||
Caddy's, it reports that and exits 0 without touching anything. Use `--force`
|
||||
to override. Always sanity-check with `--dry-run` first when unsure.
|
||||
|
||||
## Configuration
|
||||
|
||||
Only two things ever change. Both live in `~/.config/aruba-ap-cert/.env`
|
||||
(mode 600, deliberately outside the skills tree so it is never published):
|
||||
|
||||
```ini
|
||||
ARUBA_HOST=10.233.33.2:4343
|
||||
ARUBA_USERNAME=admin
|
||||
ARUBA_PASSWORD=...
|
||||
```
|
||||
|
||||
`ARUBA_HOST` accepts an IP or hostname, with port. Override per-run with
|
||||
`--host`. A real environment variable beats the file; `--env-file` points
|
||||
elsewhere.
|
||||
|
||||
Everything else is baked in: the Caddy path, PEM format, the `cert,chain,key`
|
||||
bundle order, and the `ui` certificate usage.
|
||||
|
||||
## What `update` actually does
|
||||
|
||||
1. Reads `wildcard_.luci.ooo.crt` + `.key` from Caddy's ACME store:
|
||||
`/mnt/lu-nas/docker/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.luci.ooo/`
|
||||
2. Verifies the key matches the certificate, then concatenates them as
|
||||
**cert, chain, key** — the private key must come *after* the certificate.
|
||||
3. Skips the upload if the AP already has something this new (unless `--force`).
|
||||
4. Uploads to `/swarm.cgi` (`opcode=cert-upload-new`, PEM, server slot), naming
|
||||
it after its expiry in local time — e.g. `Sep2_2026`, matching the existing
|
||||
convention on the AP.
|
||||
5. Pushes the certificate usage:
|
||||
```
|
||||
wlan cert-assignment-profile
|
||||
pki-cert-assign application ui cert-type ServerCert certname <name>
|
||||
exit
|
||||
```
|
||||
6. Prints `show cert assignment` to confirm, and deletes the temporary bundle
|
||||
(it contains the private key).
|
||||
|
||||
## Gotchas
|
||||
|
||||
- **The Web UI cert only takes effect when the AP's web server restarts.** If
|
||||
`https://aruba.luci.ooo:4343` still serves the old cert after a successful
|
||||
update, reboot the virtual controller.
|
||||
- **The AP rejects a re-upload of an identical certificate**, replying
|
||||
`Abort because Cert with same digest already exists as <name>`. This is normal
|
||||
when Caddy has not renewed yet — the idempotency check avoids hitting it.
|
||||
- **`ui` and `captive-portal` are separate usages** pointing at separate certs.
|
||||
This skill manages `ui` by default; pass `--application captive-portal` to
|
||||
move that one too.
|
||||
- The AP closes TLS without a `close_notify`, which OpenSSL 3 treats as a
|
||||
truncated response. The script sets `OP_IGNORE_UNEXPECTED_EOF`; do not
|
||||
"simplify" that adapter away or every call breaks.
|
||||
- InstantOS returns scalars as `<data name="...">`, not as named tags. The
|
||||
parser normalizes those keys; the login `sid` arrives the same way.
|
||||
- **Uploads are synchronous and the POST body is the only real result.** The web
|
||||
UI polls `opcode=upload_status&oper_id=...`, but this AP answers
|
||||
`not_available` for *every* id — including uploads that demonstrably
|
||||
succeeded. Trusting that poll reports working uploads as failures. The script
|
||||
reads the POST body for `<error>`, then confirms by looking the certificate up
|
||||
in `show cert all`. Do not reintroduce polling.
|
||||
- **Certificate types are `ServerCert` / `TrustedCA` / `ClientCert` /
|
||||
`PublicCert`.** The UI bundle appears to offer `server_cert`, `ca_cert` etc.,
|
||||
but that option list is overwritten at runtime. Sending `server_cert` fails
|
||||
with "Cert Path: cert type is unknown".
|
||||
|
||||
## When to run
|
||||
|
||||
Caddy renews roughly 30 days before expiry (the ACME renewal window is in
|
||||
`wildcard_.luci.ooo.json`). A weekly `status` is enough to catch it; run
|
||||
`update` once Caddy shows a newer date than the AP.
|
||||
|
||||
```bash
|
||||
python3 aruba_cert.py status && python3 aruba_cert.py update
|
||||
```
|
||||
+1082
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user