acme.sh/deploy
Qhilm 698f6c7329
Feat: Shelly deploy hook for firmware 2.0.0+ (#7145)
* feat: add Shelly Gen3+ deploy hook with RFC 7616 HTTP Digest auth

Adds deploy/shelly.sh for deploying Let's Encrypt HTTPS server certificates
to Shelly Gen3+ devices (Gen4 tested) via JSON-RPC over HTTP.

- RFC 7616 SHA-256 HTTP Digest authentication (Authorization header)
- Uploads fullchain.pem and private key via Shelly.PutHTTPServerCert / PutHTTPServerKey
- Auto-reboot support (SHELLY_REBOOT to disable)
- Auth auto-detection: no password = no auth, password = Digest
- Nonce counter (nc) increments per request per RFC 7616
- Tested against Shelly 2PM Gen4 (firmware 2.0.0)

Also adds deploy/test_shelly.sh for self-testing the hook logic without
a real device (mocked _post).

* fix: address review feedback on shelly deploy hook

- Fix _secure_debug calls to use two arguments (label + value)
- Remove bash-only $RANDOM cnonce fallback; openssl always available
- Parse $HTTP_HEADER directly instead of raw curl re-request
- Detect auth via HTTP 401 status line, not empty response body
- Route reboot through _shelly_rpc to rebuild auth header with correct nc
- Remove export HTTPS_INSECURE=1 (no-op for http://, leaks to other hooks)
- Clear _H1 before returning from shelly_deploy
- Prefix all helper variables with _shelly_ to avoid namespace collisions
- Delete deploy/test_shelly.sh (deploy/ files become hook names)
- Fix missing trailing newline

* fix: validate shelly JSON-RPC responses are valid JSON

Non-JSON responses like HTTP 429 'Too Many Requests' would pass
the empty-response and '"error"' checks and be reported as success.
Now reject any response that doesn't start with '{' and contain '"id"'.

* fix: add 1s delay between shelly cert/key clear and upload calls

The Shelly device has a race condition where uploading data immediately
after clearing the existing cert/key returns -103 'Missing required
argument data!'. A 1-second delay fixes this.

* fix: remove clear-before-upload in shelly deploy hook

Shelly auto-removes all three TLS files (cert, key, CA bundle) when any
single one is cleared. The old sequence clear-cert → upload-cert →
clear-key → upload-key resulted in the key clear wiping the newly
uploaded cert, leaving only the key at boot time. The mbedtls
pk_check_pair then silently skipped the HTTPS listener.

Fix: just upload directly (overwrite in place). No clearing needed.

* Fix ShellCheck SC2090 and shfmt in shelly deploy hook

SC2090: false positive on export _H1 (used quoted in _post)
shfmt: no space after "<" in _json_encode redirects

* moved  two lines to cover the whole if block

---------

Co-authored-by: neil <github@neilpang.com>
Co-authored-by: cysimons <cysimons@cisco.com>
2026-07-25 13:03:56 +08:00
..
ali_cdn.sh Update timestamp variable in ali_cdn.sh 2025-12-22 17:00:22 +08:00
ali_dcdn.sh Update timestamp function in ali_dcdn.sh 2025-12-22 17:00:31 +08:00
apache.sh deploy apache script: fix comment (dovecot/apache) 2017-03-02 08:39:31 +01:00
baidu_cdn.sh Add Baidu Cloud CDN deploy hook (#6951) 2026-07-12 16:15:59 +08:00
byteplus_alb.sh fix bug for solaris. 2026-07-17 12:38:14 +08:00
cachefly.sh format adjustment 2024-04-07 12:36:19 +00:00
cleverreach.sh Make CI happy 2021-03-30 09:18:33 +02:00
consul.sh Fix the shfmt check 2021-05-07 12:12:30 +02:00
cpanel_uapi.sh fix cpanel_uapi: pass --user to DomainInfo list_domains when run as root 2026-07-19 10:20:58 +08:00
directadmin.sh deployhook Directadmin: Support for selecting the scheme of DirectAdmin , HTTP or HTTPS 2024-06-03 16:57:51 +08:00
docker.sh deploy/docker: allow setting key file mode and owner in the container 2026-07-05 16:30:46 +08:00
dovecot.sh fix format 2017-02-19 20:40:53 +08:00
edgio.sh format adjustment 2024-04-07 12:36:19 +00:00
exim4.sh fix format 2024-10-13 17:41:22 +02:00
fortigate.sh Deploy certificate to FortiGate firewall using API (#6236) 2026-07-14 09:02:34 +08:00
fritzbox.sh deploy/fritzbox: allow hook to be used with multiple fritzboxes 2022-01-06 16:20:43 +01:00
gcore_cdn.sh fix(gcore_cdn): renew login api url (#5143) 2026-07-04 20:14:32 +08:00
gitlab.sh fix shellcheck warnings 2022-11-23 21:33:29 +08:00
haproxy.sh deploy/haproxy: use printf instead of "echo -e" for the stats socket payload 2026-07-05 15:44:26 +08:00
kemplm.sh Fixed missing error return value when certificate upload fails. 2026-02-23 09:24:06 +01:00
keychain.sh Remove template text 2018-03-22 13:45:43 -04:00
keyhelp.sh rename to keyhelp_api 2025-10-21 11:34:46 +02:00
keyhelp_api.sh rename to keyhelp_api 2025-10-21 11:34:46 +02:00
kong.sh name="snis" => name="snis[]" 2021-09-04 16:59:50 +08:00
lighttpd.sh use ${ACME_OPENSSL_BIN:-openssl} instead of openssl 2021-09-30 19:00:39 -04:00
localcopy.sh align logic to acme.sh installcert(), fix perms on non-key files 2025-12-30 11:41:50 -05:00
mailcow.sh Merge pull request #4170 from SecT0uch/patch-1 2022-07-11 22:13:24 +08:00
multideploy.sh Add _cleardeployconf to clear deploy hook keys from domain conf 2026-07-10 11:05:40 +08:00
myapi.sh exe 2017-02-05 23:14:25 +08:00
mydevil.sh mydevil: replace BSD-only cut -w with tr + plain cut 2026-07-12 10:49:49 +08:00
mysqld.sh fix format 2017-02-19 20:40:53 +08:00
netlify.sh format adjustment 2024-04-07 12:36:19 +00:00
nginx.sh fix format 2017-02-19 20:40:53 +08:00
openmediavault.sh omv deploy hook: add usage comments 2022-01-20 17:46:47 +08:00
opensshd.sh fix format 2017-02-19 20:40:53 +08:00
openstack.sh Fix CI test failure for deploy/openstack.sh 2020-07-16 13:53:21 +10:00
panos.sh deploy/panos: do not commit when the cert or key import failed (#4716) 2026-07-05 17:13:59 +08:00
peplink.sh Add Peplink deploy hook 2021-01-13 20:37:05 +00:00
proxmoxbs.sh fix proxmoxve/proxmoxbs deploy: fail on non-2xx API response 2026-07-20 10:02:54 +08:00
proxmoxve.sh fix proxmoxve/proxmoxbs deploy: fail on non-2xx API response 2026-07-20 10:02:54 +08:00
pureftpd.sh fix format 2017-02-19 20:40:53 +08:00
qiniu.sh feat(qiniu): make forceHttps configurable via environment variable 2026-01-01 13:26:02 +00:00
README.md update repo name 2020-01-30 12:06:39 +08:00
routeros.sh Fix RouterOS deploy (#7034) 2026-06-19 14:23:03 +02:00
ruckus.sh Don't deploy ECC certs to legacy Ruckus 2025-03-27 14:03:08 +13:00
shelly.sh Feat: Shelly deploy hook for firmware 2.0.0+ (#7145) 2026-07-25 13:03:56 +08:00
ssh.sh Feature: Support other shells then sh (#4877) 2026-07-10 21:02:06 +08:00
strongswan.sh Fix strongswan deploy hook 2025-12-19 18:12:45 +03:00
synology_dsm.sh deploy/synology_dsm.sh: remove bashisms, keep the hook POSIX sh 2026-07-12 16:04:44 +08:00
truenas.sh fix: remove control characters 2024-12-31 18:04:39 +01:00
truenas_ws.sh Adding custom Port definitions for truenas (#7033) 2026-07-01 20:55:55 +08:00
unifi.sh disable shellcheck 2025-11-08 16:59:10 -05:00
vault.sh check curl vault http return code 2025-04-18 00:25:10 +02:00
vault_cli.sh improve logging 2022-12-28 02:47:49 +08:00
vsftpd.sh fix format 2024-10-13 17:41:22 +02:00
windows_rdp.sh Add deployment plugin for Windows RDP via OpenSSH (#6925) 2026-05-02 10:56:13 +02:00
zyxel_gs1900.sh Apply suggested fixes from shfmt diffs 2025-05-17 21:25:39 -04:00