endef
+
+NIXIO_TLS:=axtls
+
define Package/luci-nixio
$(call Package/luci/libtemplate)
TITLE:=NIXIO Socket Library
+ DEPENDS:=
endef
define Package/luci-nixio/install
$(call Package/luci/install/template,$(1),libs/nixio)
endef
+define Package/luci-nixio/config
+ choice
+ prompt "TLS Provider"
+ default PACKAGE_luci-nixio_axtls
+
+ config PACKAGE_luci-nixio_axtls
+ bool "Builtin (axTLS)"
+ select PACKAGE_dropbear
+ select PACKAGE_dropbearconvert
+
+ config PACKAGE_luci-nixio_openssl
+ bool "OpenSSL"
+ select PACKAGE_libopenssl
+ endchoice
+endef
+
+ifneq ($(CONFIG_PACKAGE_luci-nixio_openssl),)
+ NIXIO_TLS:=openssl
+endif
+
define Package/luci-sys
$(call Package/luci/libtemplate)
LUA_SHLIBS="-llua -lm -ldl -lcrypt" \
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" \
LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \
- OS="Linux"
+ NIXIO_TLS="$(NIXIO_TLS)" OS="Linux"
$(eval $(call BuildPackage,luci-core))
src/openssl-compat.o: src/libaxtls.a src/openssl-compat.c
$(COMPILE) $(NIXIO_CFLAGS) $(LUA_CFLAGS) $(FPIC) $(TLS_CFLAGS) -c -o $@ src/openssl-compat.c
+ mkdir -p dist
+ cp -pR axtls-root/* dist/
compile: $(NIXIO_OBJ)
--- /dev/null
+#!/usr/bin/lua
+local nixio = require "nixio"
+local posix
+local defkey = nixio.meta_tls_context.tls_defaultkey
+if not defkey or io.open(defkey) then
+ os.exit(0)
+end
+
+if os.execute("which openssl") then
+ io.stderr:write("Warning: OpenSSL detected "..
+ "but it looks like nixio was linked against axtls\n")
+ os.execute("umask 0077;openssl genrsa -out '" .. defkey .. "' 2048")
+elseif os.execute("which dropbearkey && which dropbearconvert") then
+ os.execute("dropbearkey -t rsa -s 2048 -f /tmp/dbkey.rsa")
+ os.execute("umask 0077;dropbearconvert dropbear openssh /tmp/dbkey.rsa '"..defkey.."'")
+ os.remove("/tmp/dbkey.rsa")
+else
+ io.stderr:write("No key generators available! Giving up.")
+ os.exit(1)
+end