# 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://: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 ` 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 `.crt` (leaf + chain) and `.key`: ``` /mnt/lu-nas/docker/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.luci.ooo/ ``` Override with `--caddy-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 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 `. ## 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 ``, with errors in ``. | Operation | Request | | --- | --- | | Login | `opcode=login user=.. passwd=..` | | Show | `opcode=show cmd="show cert all"` | | Config push | `opcode=config cmd=""` | | 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 `success`, 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 `` element finds nothing and every login appears to fail. Tables use a separate `....` 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 ``, 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 `` with no `sid`; an expired session returns `Invalid Session ID`. `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.