px5g-genkeys 499 B

12345678910111213141516171819
  1. #!/usr/bin/lua
  2. local keyfile = "/etc/nixio/rsa_main.der"
  3. local certfile = "/etc/nixio/cert_main.der"
  4. local px5g = require "px5g"
  5. local nixio = require "nixio"
  6. local fs = require "nixio.fs"
  7. local os = require "os"
  8. nixio.umask(77)
  9. if not fs.access(certfile) then
  10. local key = px5g.genkey(2048)
  11. fs.writefile(keyfile, key:asn1())
  12. local cert = key:create_selfsigned(
  13. {CN=nixio.uname().nodename, O="LuCI Keymaster"},
  14. os.time(), os.time() + 3600 * 24 * 366 * 15)
  15. fs.writefile(certfile, cert)
  16. end