alex3305 / home-assistant-addons

Alex's Home Assistant Add-ons
https://alex3305.github.io/home-assistant-docs/
MIT License
47 stars 29 forks source link

Issue with dnsChallenge #3

Closed GoSpursGoNL closed 4 years ago

GoSpursGoNL commented 4 years ago

Thanks for this nice addon. Unfortunately I can't get it to run correctly. I changed the log level to DEBUG and see that it has trouble finding the settings for the dnsChallenge

time="2020-02-22T20:03:59+01:00" level=debug msg="Building ACME client..." providerName=le.acme time="2020-02-22T20:03:59+01:00" level=debug msg="https://acme-v02.api.letsencrypt.org/directory" providerName=le.acme time="2020-02-22T20:03:59+01:00" level=debug msg="Using DNS Challenge provider: transip" providerName=le.acme time="2020-02-22T20:03:59+01:00" level=error msg="Unable to obtain ACME certificate for domains \"ha.redacted.nl\": cannot get ACME client transip: some credentials information are missing: TRANSIP_PRIVATE_KEY_PATH" providerName=le.acme routerName=homeAssistantRouter@file rule="Host(ha.redacted.nl)"

My config is as follows:

log_level: DEBUG
access_logs: true
forwarded_headers_insecure: true
dynamic_configuration_path: /config/traefik/
letsencrypt:
  enabled: true
  email: mail@redacted.nl
  challenge_type: dnsChallenge
  provider: transip
env_vars:
  - TRANSIP_ACCOUNT_NAME=redacted
  - TRANSIP_PRIVATE_KEY_PATH=transip.key

(FTFY)

What am I doing wrong? The transip.key is in /config/traefik/ I also tried setting /config/traefik/transip.key and /transip.key In the config folder are also many HA-related files such as configuration.yaml and in there I created the traefik subdirectory. With in it 2 files, traefik.yaml and transip.key

alex3305 commented 4 years ago

According to the LEGO documentation it seems you are using the wrong configuration for your private key file. Your current configuration points to the path of the private key file, but you are trying to point at a file. However this can easily be fixed:

The environment variable names can be suffixed by _FILE to reference a file instead of a value. More information here.

So your configuration should probably be something like this:

log_level: DEBUG
access_logs: true
forwarded_headers_insecure: true
dynamic_configuration_path: /config/traefik/
letsencrypt:
  enabled: true
  email: mail@redacted.nl
  challenge_type: dnsChallenge
  provider: transip
env_vars:
  - TRANSIP_ACCOUNT_NAME=redacted
  - TRANSIP_PRIVATE_KEY_FILE=/config/traefik/transip.key

Notice the small difference in the env_vars? That should probably fix it. Otherwise you could also probably get away with: - TRANSIP_PRIVATE_KEY_FILE=/config/traefik/.

I also tried messing around with the environment variables to ensure that all works correctly:

log_level: INFO
access_logs: false
forwarded_headers_insecure: true
dynamic_configuration_path: /config/extras/traefik
letsencrypt:
  enabled: true
  email: some-email@example.com
  challenge_type: dnsChallenge
  provider: cloudflare
env_vars:
  - CF_DNS_API_TOKEN=some-cf-api-token
  - SECOND_ENV_VAR=some_value
$ printenv
HOSTNAME=32de6d38-traefik
PWD=/
TZ=Europe/Amsterdam
HOME=/root
LANG=C.UTF-8
__BASHIO_BIN=/usr/lib/bashio/bashio
CF_DNS_API_TOKEN=some-cf-api-token
SECOND_ENV_VAR=some_value
HASSIO_TOKEN=long-hex-string
TERM=xterm
SUPERVISOR_TOKEN=long-hex-string
SHLVL=2
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/bin/printenv

But it seems it does work correctly. Also switching around the environment variables doesn't make a difference. Both are picked up correctly by the add-on. So my guess it's the small difference in configuration on your side.

Please let me know if this fixes your issue.

alex3305 commented 4 years ago

@GoSpursGoNL Did my post above help you solve your issue?

GoSpursGoNL commented 4 years ago

For the moment I switched to DuckDNS. Hopefully this weekend I can test your addon again.

GoSpursGoNL commented 4 years ago

Unfortunately still the same error, thanks for thinking along though Alex. I'll stick with duckdns for the moment since it also has handy dynamic dns functionality.

alex3305 commented 4 years ago

@GoSpursGoNL I'm sorry you couldn't get it to work. I would like to see which configuration you have tried to use. Perhaps that could help me with future issues. Otherwise I'm still happy to help you out if you want.

GoSpursGoNL commented 4 years ago

I used the configuration you provided, the error was the same. But for the moment I am happy with duckdns. Have a good weekend!