summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/axtls-root
diff options
context:
space:
mode:
Diffstat (limited to 'libs/nixio/axtls-root')
-rwxr-xr-xlibs/nixio/axtls-root/etc/uci-defaults/nixio2
-rwxr-xr-xlibs/nixio/axtls-root/usr/sbin/nixio-axtls-checkkey20
2 files changed, 22 insertions, 0 deletions
diff --git a/libs/nixio/axtls-root/etc/uci-defaults/nixio b/libs/nixio/axtls-root/etc/uci-defaults/nixio
new file mode 100755
index 000000000..4f342628a
--- /dev/null
+++ b/libs/nixio/axtls-root/etc/uci-defaults/nixio
@@ -0,0 +1,2 @@
+#!/bin/sh
+nixio-axtls-checkkey
diff --git a/libs/nixio/axtls-root/usr/sbin/nixio-axtls-checkkey b/libs/nixio/axtls-root/usr/sbin/nixio-axtls-checkkey
new file mode 100755
index 000000000..994f24e7b
--- /dev/null
+++ b/libs/nixio/axtls-root/usr/sbin/nixio-axtls-checkkey
@@ -0,0 +1,20 @@
+#!/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