blob: 981c66744efc5f52c4ac936197663d5d5cb9bc3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/lua
os.exit(0) --ToDo
local nixio = require "nixio"
local fs = require "nixio.fs"
local posix
local defkey = nixio.meta_tls_context.tls_defaultkey
local okey = "646e6b90d1ad02719cb1b221b7ce447a"
if not defkey or (io.open(defkey) and
(nixio.crypto.hash("md5"):update(fs.readfile(defkey)):final()) ~= okey) then
os.exit(0)
end
if os.execute("which openssl >/dev/null") == 0 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 >/dev/null && which dropbearconvert >/dev/null") == 0 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
|