uhttpd: update

This commit is contained in:
CN_SZTL 2019-10-31 13:02:28 +08:00
parent 39a7898a84
commit 17252389b7
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
3 changed files with 23 additions and 7 deletions

View File

@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=uhttpd
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/uhttpd.git
PKG_SOURCE_DATE:=2018-11-28
PKG_SOURCE_VERSION:=cdfc902a4cb77bc538a729f9e1c8a8578454a0e5
PKG_MIRROR_HASH:=6b21111547a4453355bd6c941a47f0116a652a77d87c1e05a035168b8ab2aa6f
PKG_SOURCE_DATE:=2019-08-17
PKG_SOURCE_VERSION:=6b03f9605323df23d12e3876feb466f53f8d50c4
PKG_MIRROR_HASH:=4df96054a4fce659e6c849feae7850d542b37ad5caffc1485b7a63c7c2764cb1
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=ISC
@ -34,7 +34,7 @@ endef
define Package/uhttpd
$(Package/uhttpd/default)
DEPENDS:=+libubox +libblobmsg-json +libjson-script
DEPENDS:=+libubox +libblobmsg-json +libjson-script +libjson-c
endef
define Package/uhttpd/description

View File

@ -5,8 +5,12 @@ config uhttpd main
list listen_http 0.0.0.0:80
list listen_http [::]:80
# HTTPS listen addresses, multiple allowed
list listen_https 0.0.0.0:443
list listen_https [::]:443
# Redirect HTTP requests to HTTPS if possible
option redirect_https 0
option redirect_https 1
# Server document root
option home /www
@ -114,9 +118,17 @@ config cert defaults
# Validity time
option days 730
# key type: rsa or ec
option key_type rsa
# RSA key size
option bits 2048
# EC curve name
# Curve names vary between mbedtls/px5g and openssl
# P-256 or P-384 are guaranteed to work
option ec_curve P-256
# Location
option country ZZ
option state Somewhere

View File

@ -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}"