Files
aruba-cert/README.md
T
lucioandClaude Opus 5 dd608e6a20 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]>
2026-07-27 03:58:14 -07:00

7.7 KiB

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

pip install requests cryptography

Python 3.9+. Works with cryptography 41 and newer.

Commands

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:

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:

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:

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:

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.