How to change default server_cert.pem in docker

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
freekdk
Posts: 39
Joined: Monday 01 February 2021 16:33
Target OS: Linux
Domoticz version: V2025.1
Location: Netherlands
Contact:

How to change default server_cert.pem in docker

Post by freekdk »

I found the command "docker cp <path/to/new>server_cert.pem <image-id>:/opt/domoticz/" to copy a new file server_cert.pem into the docker image.
This will be done after saving the default version of this file inside the image.

I wonder if a simple restart of the docker image will enable the use of that file. I used the same file in a system with domoticz as a normal systemd service.
User avatar
waltervl
Posts: 7020
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2026.3
Location: NL
Contact:

Re: How to change default server_cert.pem in docker

Post by waltervl »

You can use the docker EXTRA_CMD_ARG option in the docker compose yml file to set the certificate. It can be outside the docker as long as it is visible from inside the container (eg in the external folder you have mounted to /opt/domoticz/userdata). Then after an update of the docker container nothing has to be copied/updated with certificates into the container.
https://hub.docker.com/r/domoticz/domot ... ent-values
-sslwww port (for example -sslwww 443, or -sslwww 0 to disable https)

-sslcert file_path (for example /opt/domoticz/server_cert.pem)

-sslkey file_path (if different from certificate file)

-sslpass passphrase (to access to server private key in certificate)

-sslmethod method (supported methods: tlsv1, tlsv1_server, sslv23, sslv23_server, tlsv11, tlsv11_server, tlsv12, tlsv12_server)

-ssloptions options (for SSL options, default is 'default_workarounds,no_sslv2,no_sslv3,no_tlsv1,no_tlsv1_1,single_dh_use')

-ssldhparam file_path (for SSL DH parameters)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
freekdk
Posts: 39
Joined: Monday 01 February 2021 16:33
Target OS: Linux
Domoticz version: V2025.1
Location: Netherlands
Contact:

Re: How to change default file server_cert.pem in docker image

Post by freekdk »

I copied the with LetsEncrypt made file server_cert.pem, with key and dh.pem, to /opt/domoticz/config/. This makes this file visible in docker in /opt/domoticz/userdata/ . I moved the standard file /opt/domoticz/server_cert.pem in the docker image to /opt/domoticz/server_cert.pem.org and made a logical link /opt/domoticz/server_cert.pem pointing to /opt/domoticz/userdata/server_cert.pem. After a restart I do have access to domoticz via https port 8443. Before this move the browser did not like the self signed certificate.

I also first tried to add the line:

Code: Select all

      - EXTRA_CMD_ARG="-sslcert /opt/domoticz/userdata/server_cert.pem"
at the end of file /opt/domoticz/docker-compose.yml, but that did not work.
In both cases I did a restart of the docker container.
Post Reply