You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
4.9 KiB

  1. --[[
  2. LuCI - Lua Configuration Interface
  3. Copyright 2016 Toke Høiland-Jørgensen <toke@toke.dk>
  4. # This program is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License as published by the Free Software
  6. # Foundation; either version 3 of the License, or (at your option) any later
  7. # version.
  8. ]]--
  9. local ipkg = require "luci.model.ipkg"
  10. local nginx_presence = ipkg.installed("nginx-all-module") or ipkg.installed("nginx-ssl") or false
  11. local uhttpd_presence = ipkg.installed("uhttpd") or false
  12. m = Map("acme", translate("ACME certificates"),
  13. translate("This configures ACME (Letsencrypt) automatic certificate installation. " ..
  14. "Simply fill out this to have the router configured with Letsencrypt-issued " ..
  15. "certificates for the web interface. " ..
  16. "Note that the domain names in the certificate must already be configured to " ..
  17. "point at the router's public IP address. " ..
  18. "Once configured, issuing certificates can take a while. " ..
  19. "Check the logs for progress and any errors."))
  20. s = m:section(TypedSection, "acme", translate("ACME global config"))
  21. s.anonymous = true
  22. st = s:option(Value, "state_dir", translate("State directory"),
  23. translate("Where certs and other state files are kept."))
  24. st.rmempty = false
  25. st.datatype = "directory"
  26. ae = s:option(Value, "account_email", translate("Account email"),
  27. translate("Email address to associate with account key."))
  28. ae.rmempty = false
  29. ae.datatype = "minlength(1)"
  30. d = s:option(Flag, "debug", translate("Enable debug logging"))
  31. d.rmempty = false
  32. cs = m:section(TypedSection, "cert", translate("Certificate config"))
  33. cs.anonymous = false
  34. cs.addremove = true
  35. e = cs:option(Flag, "enabled", translate("Enabled"))
  36. e.rmempty = false
  37. us = cs:option(Flag, "use_staging", translate("Use staging server"),
  38. translate("Get certificate from the Letsencrypt staging server " ..
  39. "(use for testing; the certificate won't be valid)."))
  40. us.rmempty = false
  41. kl = cs:option(Value, "keylength", translate("Key length"),
  42. translate("Number of bits (minimum 2048)."))
  43. kl.rmempty = false
  44. kl.datatype = "and(uinteger,min(2048))"
  45. if uhttpd_presence then
  46. u = cs:option(Flag, "update_uhttpd", translate("Use for uhttpd"),
  47. translate("Update the uhttpd config with this certificate once issued " ..
  48. "(only select this for one certificate)." ..
  49. "Is also available luci-app-uhttpd to configure uhttpd form the LuCI interface."))
  50. u.rmempty = false
  51. end
  52. if nginx_presence then
  53. u = cs:option(Flag, "update_nginx", translate("Use for nginx"),
  54. translate("Update the nginx config with this certificate once issued " ..
  55. "(only select this for one certificate)." ..
  56. "Nginx must support ssl, if not it won't start as it needs to be " ..
  57. "compiled with ssl support to use cert options"))
  58. u.rmempty = false
  59. end
  60. wr = cs:option(Value, "webroot", translate("Webroot directory"),
  61. translate("Webserver root directory. Set this to the webserver " ..
  62. "document root to run Acme in webroot mode. The web " ..
  63. "server must be accessible from the internet on port 80."))
  64. wr.optional = true
  65. dom = cs:option(DynamicList, "domains", translate("Domain names"),
  66. translate("Domain names to include in the certificate. " ..
  67. "The first name will be the subject name, subsequent names will be alt names. " ..
  68. "Note that all domain names must point at the router in the global DNS."))
  69. dom.datatype = "list(string)"
  70. dns = cs:option(Value, "dns", translate("DNS API"),
  71. translate("To use DNS mode to issue certificates, set this to the name of a DNS API supported by acme.sh. " ..
  72. "See https://github.com/Neilpang/acme.sh/tree/master/dnsapi for the list of available APIs. " ..
  73. "In DNS mode, the domain name does not have to resolve to the router IP. " ..
  74. "DNS mode is also the only mode that supports wildcard certificates. " ..
  75. "Using this mode requires the acme-dnsapi package to be installed."))
  76. dns.optional = true
  77. cred = cs:option(DynamicList, "credentials", translate("DNS API credentials"),
  78. translate("The credentials for the DNS API mode selected above. " ..
  79. "See https://github.com/Neilpang/acme.sh/tree/master/dnsapi#how-to-use-dns-api for the format of credentials required by each API. " ..
  80. "Add multiple entries here in KEY=VAL shell variable format to supply multiple credential variables."))
  81. cred.datatype = "list(string)"
  82. return m