Rework LuCI build system
[project/luci.git] / libs / luci-lib-px5g / root / usr / sbin / px5g-genkeys
1 #!/usr/bin/lua
2 local keyfile = "/etc/nixio/rsa_main.der"
3 local certfile = "/etc/nixio/cert_main.der"
4
5 local px5g = require "px5g"
6 local nixio = require "nixio"
7 local fs = require "nixio.fs"
8 local os = require "os"
9 nixio.umask(77)
10
11 if not fs.access(certfile) then
12         local key = px5g.genkey(2048)
13         fs.writefile(keyfile, key:asn1())
14
15         local cert = key:create_selfsigned(
16                 {CN=nixio.uname().nodename, O="LuCI Keymaster"},
17                 os.time(), os.time() + 3600 * 24 * 366 * 15)
18         fs.writefile(certfile, cert)
19 end