aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/uhttpd/files/uhttpd.init
diff options
context:
space:
mode:
authorEneas U de Queiroz <cotequeiroz@gmail.com>2019-08-05 15:34:39 -0300
committerChristian Lamparter <chunkeey@gmail.com>2019-09-01 00:35:11 +0200
commit7f2b230b3b9d0a7fb758db3a9b1958845506a5a3 (patch)
treea43c4a20b4794808a8ec94c952c60bf11c560b46 /package/network/services/uhttpd/files/uhttpd.init
parenta552ababd4ff8e91d3f03f7496f12d080a71ba28 (diff)
downloadupstream-7f2b230b3b9d0a7fb758db3a9b1958845506a5a3.tar.gz
upstream-7f2b230b3b9d0a7fb758db3a9b1958845506a5a3.tar.bz2
upstream-7f2b230b3b9d0a7fb758db3a9b1958845506a5a3.zip
uhttpd: add support to generate EC keys
This adds the key_type and ec_curve options to enable the generation of EC keys during initialization, using openssl or the new options added to px5g. Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
Diffstat (limited to 'package/network/services/uhttpd/files/uhttpd.init')
-rwxr-xr-xpackage/network/services/uhttpd/files/uhttpd.init6
1 files changed, 5 insertions, 1 deletions
diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init
index dc496b3e28..6322473b97 100755
--- a/package/network/services/uhttpd/files/uhttpd.init
+++ b/package/network/services/uhttpd/files/uhttpd.init
@@ -43,15 +43,19 @@ generate_keys() {
config_get state "$cfg" state
config_get location "$cfg" location
config_get commonname "$cfg" commonname
+ config_get key_type "$cfg" key_type
+ config_get ec_curve "$cfg" ec_curve
# Prefer px5g for certificate generation (existence evaluated last)
local GENKEY_CMD=""
+ local KEY_OPTS="rsa:${bits:-2048}"
local UNIQUEID=$(dd if=/dev/urandom bs=1 count=4 | hexdump -e '1/1 "%02x"')
+ [ "$key_type" = "ec" ] && KEY_OPTS="ec -pkeyopt ec_paramgen_curve:${ec_curve:-P-256}"
[ -x "$OPENSSL_BIN" ] && GENKEY_CMD="$OPENSSL_BIN req -x509 -sha256 -outform der -nodes"
[ -x "$PX5G_BIN" ] && GENKEY_CMD="$PX5G_BIN selfsigned -der"
[ -n "$GENKEY_CMD" ] && {
$GENKEY_CMD \
- -days ${days:-730} -newkey rsa:${bits:-2048} -keyout "${UHTTPD_KEY}.new" -out "${UHTTPD_CERT}.new" \
+ -days ${days:-730} -newkey ${KEY_OPTS} -keyout "${UHTTPD_KEY}.new" -out "${UHTTPD_CERT}.new" \
-subj /C="${country:-ZZ}"/ST="${state:-Somewhere}"/L="${location:-Unknown}"/O="${commonname:-OpenWrt}$UNIQUEID"/CN="${commonname:-OpenWrt}"
sync
mv "${UHTTPD_KEY}.new" "${UHTTPD_KEY}"