Disable checkkey for now: Something is wrong with dropbearkey
[project/luci.git] / libs / nixio / axtls-root / usr / sbin / nixio-axtls-checkkey
1 #!/usr/bin/lua
2 os.exit(0)      --ToDo
3
4 local nixio = require "nixio"
5 local fs = require "nixio.fs"
6 local posix
7 local defkey = nixio.meta_tls_context.tls_defaultkey
8 local okey = "646e6b90d1ad02719cb1b221b7ce447a"
9
10 if not defkey or (io.open(defkey) and
11 (nixio.crypto.hash("md5"):update(fs.readfile(defkey)):final()) ~= okey) then
12         os.exit(0)
13 end
14
15 if os.execute("which openssl >/dev/null") == 0 then
16         io.stderr:write("Warning: OpenSSL detected "..
17         "but it looks like nixio was linked against axtls\n")
18         os.execute("umask 0077;openssl genrsa -out '" .. defkey .. "' 2048")
19 elseif os.execute("which dropbearkey >/dev/null && which dropbearconvert >/dev/null") == 0 then
20         os.execute("dropbearkey -t rsa -s 2048 -f /tmp/dbkey.rsa")
21         os.execute("umask 0077;dropbearconvert dropbear openssh /tmp/dbkey.rsa '"..defkey.."'")
22         os.remove("/tmp/dbkey.rsa")
23 else
24         io.stderr:write("No key generators available! Giving up.")
25         os.exit(1)
26 end