hassio-addons / addon-grafana

Grafana - Home Assistant Community Add-ons
https://addons.community
MIT License
213 stars 61 forks source link

Cannot use /share/mountpoint as a path for ssl cert/key #401

Closed arsenicks closed 1 month ago

arsenicks commented 1 month ago

Problem/Motivation

I'm trying to configure ssl in the addon. My ssl certs are generated by a container outside of HA and are accessible on an NFS share to use by all my other services/apps. I connected this nfs share in HA and it's accessible under the /share/ssl_certs/folder for fullchain.pem and privkey.pem.

I configured grafana addon with this path to use those certs but the addon refuse to use it because it expect the certs/key to be in /ssl/. Since issue #397 is merged the /share folder should now be accessible(thanks btw). If we can access, it make sense we could use it to store ssl certs.

Expected behavior

I expect to Simply configure the path for the ssl cert and privkey wathever the path should be or at the very least, if there's no path and just the filename(default) it looks in /ssl/ but if there's a path, use the full path provided.

Actual behavior

Addon doesn't start, error:

[19:26:00] FATAL: [19:26:00] FATAL: SSL has been enabled using the 'ssl' option, [19:26:00] FATAL: this requires an SSL certificate file which is [19:26:00] FATAL: configured using the 'certfile' option in the [19:26:00] FATAL: add-on configuration. [19:26:00] FATAL: [19:26:00] FATAL: Unfortunately, the file specified in the [19:26:00] FATAL: 'certfile' option does not exist. [19:26:00] FATAL: [19:26:00] FATAL: Please ensure the certificate file exists and [19:26:00] FATAL: is placed in the '/ssl/' directory. [19:26:00] FATAL: [19:26:00] FATAL: In case you don't have SSL yet, consider getting [19:26:00] FATAL: an SSL certificate or setting the 'ssl' option [19:26:00] FATAL: to 'false' in case you are not planning on using [19:26:00] FATAL: SSL with this add-on. [19:26:00] FATAL: [19:26:00] FATAL: Check the add-on manual for more information.

Steps to reproduce

Simply try to configure ssl certs in /share/wathever folder.

Proposed changes

Accept /share/ and /ssl folders for cert and key.

arsenicks commented 1 month ago

Workaround for now, you can set the path to Ex. "../share/ssl_certs/fullchain.pem"

Once saved, you can restart grafana and it work. But in the addon configuration UI in ha, the path doesn't retain the "../" so if you change another setting and restart, grafana will not start untill you put the "../" back again.

arsenicks commented 1 month ago

Here's a proposed fix for this but as mentionned on the PR, it would need to be tested with existing install to confirm updating to this change would not break people install created using the current default hardcoded path.

Let me know what you think about this. I will submit an update to the documentation to add details if this PR is accepted.

sinclairpaul commented 1 month ago

Closing as per #402