Files
RustProxy/integrations/opnsense-acme
2026-11-14 17:24:12 +01:00
..
2026-11-14 17:24:12 +01:00
2026-11-14 17:24:12 +01:00
2026-11-14 17:24:12 +01:00
2026-11-14 17:24:12 +01:00

OPNsense os-acme-client -> RustProxy

Deploys certificates issued by the OPNsense os-acme-client plugin (Services -> ACME Client) to RustProxy through POST /api/certificates/deploy. The script runs as an ACME Client automation ("System or Plugin Command"), so every issued or renewed certificate is sent to RustProxy right away. Works with RustProxy 0.28.2 or newer; error hints match RustProxy 0.37.

Files

  • opnsense-rustproxy-cert-deploy.sh - finds the os-acme-client certificates, checks them and uploads them.
  • rustproxy-acme.conf.example - RustProxy URL, certificate API credential and the certificate mapping.
  • actions_rustproxy_cert.conf - configd action Deploy certificates to RustProxy, offered by the ACME Client automation and by Cron.

1. RustProxy credential

In RustProxy open Settings -> Certificate API and create (or edit) a key:

  • Allowed certificate IDs: every RustProxy certificate id used below (the right side of RUSTPROXY_CERTIFICATES), one per line. * is not accepted; a key migrated from an older version with * must get the explicit list when it is edited. The ids do not have to exist yet: the first deploy creates them.
  • Also allow deploy: enabled. Keys created before 0.28.2 were migrated as reload-only and get HTTP 403 certificate_api.deploy_forbidden.

Copy the key id and the token (the token is shown only once; regenerate it if lost).

2. Installation (OPNsense root shell, SSH or console option 8)

cat > /usr/local/sbin/opnsense-rustproxy-cert-deploy.sh <<'RUSTPROXY_EOF'
<paste the content of opnsense-rustproxy-cert-deploy.sh>
RUSTPROXY_EOF
chmod 750 /usr/local/sbin/opnsense-rustproxy-cert-deploy.sh

cat > /usr/local/etc/rustproxy-acme.conf <<'RUSTPROXY_EOF'
<paste rustproxy-acme.conf.example and fill in the values>
RUSTPROXY_EOF
chmod 600 /usr/local/etc/rustproxy-acme.conf

cat > /usr/local/opnsense/service/conf/actions.d/actions_rustproxy_cert.conf <<'RUSTPROXY_EOF'
<paste the content of actions_rustproxy_cert.conf>
RUSTPROXY_EOF
service configd restart

Alternatively copy the three files with scp.

3. Which certificates are sent

os-acme-client keeps the files in /var/etc/acme-client/certs/<id>/fullchain.pem and /var/etc/acme-client/keys/<id>/private.key. The <id> is an internal id that the GUI does not show, so the script finds the certificate by name (the Common Name or any Alt Name of the ACME certificate):

/usr/local/sbin/opnsense-rustproxy-cert-deploy.sh --list
66a1b2c3d4e5f  *.apps.example.com apps.example.com (valid until Dec 14 13:43:31 2026 GMT)

Map each name to a RustProxy certificate id (A-Z a-z 0-9 _ -, max 64), separated by spaces:

RUSTPROXY_CERTIFICATES='*.apps.example.com=apps-wildcard example.com=example-com'

Every run sends all mapped certificates. A certificate that did not change is a no-op in RustProxy, a missing id is created as a manual certificate and changed material is rotated atomically. RustProxy-managed ACME ids are rejected (409). When several ACME certificates carry the same name, the one valid longest is used.

A single certificate can also be set with CERTIFICATE_ID plus ACME_CERT_NAME, or with explicit CERT_FILE and KEY_FILE.

4. Connection settings

Setting Meaning
RUSTPROXY_URL Panel origin only: https://name:port (no path).
RUSTPROXY_KEY_ID, RUSTPROXY_TOKEN Certificate API credential.
RUSTPROXY_TLS_VERIFY yes (default) verifies the panel certificate; no accepts a self-signed or not yet valid panel certificate.
RUSTPROXY_CACERT PEM file of a private CA that signed the panel certificate (keeps verification on).
RUSTPROXY_PINNED_PUBKEY sha256//BASE64 pin of the panel key. Recommended together with RUSTPROXY_TLS_VERIFY='no'.
RUSTPROXY_RESOLVE name:port:address - connect to a fixed IP while using the panel name for TLS and the Host header.
RUSTPROXY_ALLOW_HTTP yes allows http:// to a remote host. Only for a trusted reverse proxy that terminates HTTPS in front of RustProxy; otherwise RustProxy answers 403 certificate_api.https_required. http://127.0.0.1 always works.

Panel without a valid certificate

Pin of a self-signed panel certificate (recommended):

echo | openssl s_client -connect rustproxy.lan:9090 -servername rustproxy.lan 2>/dev/null \
  | openssl x509 -pubkey -noout | openssl pkey -pubin -outform DER \
  | openssl dgst -sha256 -binary | openssl enc -base64
RUSTPROXY_TLS_VERIFY='no'
RUSTPROXY_PINNED_PUBKEY='sha256//<output of the command above>'

Without the pin only RUSTPROXY_TLS_VERIFY='no' is needed; the script then logs a warning on every run.

Host name

RustProxy accepts only the host names listed in Settings -> Administration (public panel HTTPS origin and additional allowed DNS hostnames) or an IP literal. Another DNS name gives 403 auth.invalid_host. When the panel name does not resolve on OPNsense, keep the name in RUSTPROXY_URL and add RUSTPROXY_RESOLVE='name:port:IP'.

5. Test

/usr/local/sbin/opnsense-rustproxy-cert-deploy.sh --check
configctl rustproxy_cert deploy

--check finds the mapped certificates and validates key match and expiry without contacting RustProxy. configctl runs exactly what the automation runs. A successful upload prints:

RustProxy certificate reconcile succeeded (HTTP 200, id=apps-wildcard)

Every run is also written to the system log (tag rustproxy-acme, System -> Log Files -> General).

6. ACME Client automation

  1. Services -> ACME Client -> Automations -> +: Run Command = System or Plugin Command, System Command = Deploy certificates to RustProxy, give it a name and save.
  2. Services -> ACME Client -> Certificates: edit each mapped certificate and add the automation under Automations.
  3. Click Run automations (paper plane icon) on the certificate to test it.

From now on the deploy runs after every issue or renewal. The ACME Client log shows running automation (configd), the result is in the system log.

Optionally also schedule Deploy certificates to RustProxy in System -> Settings -> Cron (for example daily) to repair drift when a certificate was changed or removed on the RustProxy side.

Errors

On failure the script prints the HTTP status, the RustProxy error code and a hint.

Response Cause
403 certificate_api.deploy_forbidden Key is reload-only: enable Also allow deploy.
403 certificate_api.certificate_forbidden Key does not include that certificate id.
403 certificate_api.https_required http:// used from a non-loopback address.
403 auth.invalid_host Host name in RUSTPROXY_URL is not allowed by the panel.
403 auth.invalid_origin Scheme/host does not match the pinned public panel origin or trusted proxy settings.
401 certificate_api.invalid_token Wrong key id or token, or the token was regenerated.
409 The id belongs to a RustProxy-managed ACME certificate.
no os-acme-client certificate for NAME Name not found: compare with --list.