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.

109 lines
5.0 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(ListValue, "keylength", translate("Key size"),
  42. translate("Key size (and type) for the generated certificate."))
  43. kl:value("2048", "RSA 2048 bits")
  44. kl:value("3072", "RSA 3072 bits")
  45. kl:value("4096", "RSA 4096 bits")
  46. kl:value("ec-256", "ECC 256 bits")
  47. kl:value("ec-384", "ECC 384 bits")
  48. kl.default = "2048"
  49. kl.rmempty = false
  50. if uhttpd_presence then
  51. u = cs:option(Flag, "update_uhttpd", translate("Use for uhttpd"),
  52. translate("Update the uhttpd config with this certificate once issued " ..
  53. "(only select this for one certificate)." ..
  54. "Is also available luci-app-uhttpd to configure uhttpd form the LuCI interface."))
  55. u.rmempty = false
  56. end
  57. if nginx_presence then
  58. u = cs:option(Flag, "update_nginx", translate("Use for nginx"),
  59. translate("Update the nginx config with this certificate once issued " ..
  60. "(only select this for one certificate)." ..
  61. "Nginx must support ssl, if not it won't start as it needs to be " ..
  62. "compiled with ssl support to use cert options"))
  63. u.rmempty = false
  64. end
  65. wr = cs:option(Value, "webroot", translate("Webroot directory"),
  66. translate("Webserver root directory. Set this to the webserver " ..
  67. "document root to run Acme in webroot mode. The web " ..
  68. "server must be accessible from the internet on port 80."))
  69. wr.optional = true
  70. dom = cs:option(DynamicList, "domains", translate("Domain names"),
  71. translate("Domain names to include in the certificate. " ..
  72. "The first name will be the subject name, subsequent names will be alt names. " ..
  73. "Note that all domain names must point at the router in the global DNS."))
  74. dom.datatype = "list(string)"
  75. dns = cs:option(Value, "dns", translate("DNS API"),
  76. translate("To use DNS mode to issue certificates, set this to the name of a DNS API supported by acme.sh. " ..
  77. "See https://github.com/Neilpang/acme.sh/tree/master/dnsapi for the list of available APIs. " ..
  78. "In DNS mode, the domain name does not have to resolve to the router IP. " ..
  79. "DNS mode is also the only mode that supports wildcard certificates. " ..
  80. "Using this mode requires the acme-dnsapi package to be installed."))
  81. dns.optional = true
  82. cred = cs:option(DynamicList, "credentials", translate("DNS API credentials"),
  83. translate("The credentials for the DNS API mode selected above. " ..
  84. "See https://github.com/Neilpang/acme.sh/tree/master/dnsapi#how-to-use-dns-api for the format of credentials required by each API. " ..
  85. "Add multiple entries here in KEY=VAL shell variable format to supply multiple credential variables."))
  86. cred.datatype = "list(string)"
  87. return m