Skip to content

Commit 8cead9a

Browse files
committed
LetsEncrypt: Allow to set User-Agent
* Add user_agent and user_agent_comment that directly map to certbot arguments of same name.
1 parent 90e68a9 commit 8cead9a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

letsencrypt/DOCS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,25 @@ When you specify a custom ACME server, the *Dry Run* and *Issue test certificate
255255

256256
</details>
257257

258+
<details>
259+
<summary>Change User-Agent</summary>
260+
261+
For auditing purposes it might be useful to override User-Agent HTTP header that addon and its providers send when making requests.
262+
263+
Setting field `user_agent` will completely override value of User-Agent:
264+
265+
```yaml
266+
user_agent: "HomeAssistant"
267+
```
268+
269+
Setting field `user_agent_comment` will add value to CertBot User-Agent header:
270+
271+
```yaml
272+
user_agent_comment: "HomeAssistant"
273+
```
274+
275+
</details>
276+
258277
<details>
259278
<summary>Selecting the Key Type</summary>
260279

letsencrypt/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ schema:
169169
elliptic_curve: list(secp256r1|secp384r1)?
170170
acme_server: url?
171171
acme_root_ca_cert: str?
172+
user_agent: str?
173+
user_agent_comment: str?
172174
verbose: bool?
173175
dry_run: bool?
174176
test_cert: bool?

letsencrypt/rootfs/etc/services.d/lets-encrypt/run

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ CHALLENGE=$(bashio::config 'challenge')
1919
DNS_PROVIDER=$(bashio::config 'dns.provider')
2020
ACME_SERVER=$(bashio::config 'acme_server')
2121
ACME_ROOT_CA_CERT=$(bashio::config 'acme_root_ca_cert')
22+
USER_AGENT=$(bashio::config 'user_agent')
23+
USER_AGENT_COMMENT=$(bashio::config 'user_agent_comment')
2224
EAB_KID=$(bashio::config 'eab_kid')
2325
EAB_HMAC_KEY=$(bashio::config 'eab_hmac_key')
2426
DRY_RUN=$(bashio::config 'dry_run')
@@ -354,6 +356,14 @@ if [ "${VERBOSE}" = "true" ]; then
354356
ADDITIONAL_ARGS+=("-vvv")
355357
fi
356358

359+
# Add user agent if set
360+
if [ -n "${USER_AGENT}" ]; then
361+
ADDITIONAL_ARGS+=("--user-agent" "${USER_AGENT}")
362+
fi
363+
if [ -n "${USER_AGENT_COMMENT}" ]; then
364+
ADDITIONAL_ARGS+=("--user-agent-comment" "${USER_AGENT_COMMENT}")
365+
fi
366+
357367
# Gather all domains into a plaintext file
358368
DOMAIN_ARR=()
359369
for line in $DOMAINS; do

0 commit comments

Comments
 (0)