[FS#4121] uhttpd: checked and used certificate are different in uhttpd.init
OpenWrt Bugs
openwrt-bugs at lists.openwrt.org
Thu Nov 4 02:40:46 PDT 2021
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Jan Breuer (j123b567)
Attached to Project - OpenWrt/LEDE Project
Summary - uhttpd: checked and used certificate are different in uhttpd.init
Task Type - Bug Report
Category - Base system
Status - Unconfirmed
Assigned To -
Operating System - All
Severity - Low
Priority - Very Low
Reported Version - Trunk
Due in Version - Undecided
Due Date - Undecided
Details - uhttpd init script checks different certificate files then it finally uses in some situations. This causes uhttpd fail to start.
In the init script, there are lines
config_get UHTTPD_KEY "$cfg" key /etc/uhttpd.key
config_get UHTTPD_CERT "$cfg" cert /etc/uhttpd.crt
Some checks are performed on UHTTPD_KEY and UHTTPD_CERT and later, there is
append_arg "$cfg" cert "-C"
append_arg "$cfg" key "-K"
This can cause problem if key or cert option is missing. In the first place, defalt value is used and in the second place, empty string is used.
Deleting key and cert option and restarting uhttpd will pass all checks, new certificate and key will be generated in default location and later, empty certificate and key paths are passed to uhttpd which will fail.
I would like to send PR to fix this but I would like to ask for the best solution. Naive approach would be to just do
append_arg "$cfg" cert "-C" "$UHTTPD_CERT"
append_arg "$cfg" key "-K" "$UHTTPD_KEY"
So it will fallback to already resolved values and at least don't fail, if key and cert are both missing.
Unfortunately, this can cause other problems comes with LuCI, where there is easily possible to screw up the upload completely and for example delete the certificate option and keeping the key option.
In this example UHTTPD_KEY will contain new key and UHTTPD_CERT will contain unrelated old certificate, which is wrong and again uhttpd fail to start completely.
After reading the source code of the init script, it seems, that the default fallback values never worked, so it would be safe to do solution like this
config_get UHTTPD_KEY "$cfg" key
config_get UHTTPD_CERT "$cfg" cert
This is also more robust to wrong configurations from LuCI because at least pure HTTP will be available in most cases.
Default values /etc/uhttpd.key and /etc/uhttpd.crt are still present in default uci config, so nothing should change for anybody and it will just be more robust to wrong configuration from LuCI.
More information can be found at the following URL:
https://bugs.openwrt.org/index.php?do=details&task_id=4121
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
More information about the openwrt-bugs
mailing list