diff --git a/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js b/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js index 50f47d546bf5..6479fd751ebf 100644 --- a/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js +++ b/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js @@ -1,6 +1,7 @@ 'use strict'; 'require form'; 'require fs'; +'require uci'; 'require view'; return view.extend({ @@ -451,12 +452,32 @@ return view.extend({ o = s.taboption('advanced', form.ListValue, "key_type", _("Key size"), _("Key size (and type) for the generated certificate.")); + o.value("", _("Select")); o.value("rsa2048", _("RSA 2048 bits")); o.value("rsa3072", _("RSA 3072 bits")); o.value("rsa4096", _("RSA 4096 bits")); o.value("ec256", _("ECC 256 bits")); o.value("ec384", _("ECC 384 bits")); - o.default = "ec256"; + o.cfgvalue = function(section_id, set_value) { + var keylength = uci.get('acme', section_id, 'keylength'); + if (keylength) { + // migrate old RSA to new keytype + switch (keylength) { + case "2048": return "rsa2048"; + case "3072": return "rsa3072"; + case "4096": return "rsa4096"; + case "ec-256": return "ec256"; + case "ec-384": return "ec384"; + default: return ""; // bad value + } + } + return set_value; + }; + o.write = function(section_id, value) { + // remove old keylength + uci.set('acme', section_id, 'keylength', ''); + uci.set('acme', section_id, 'key_type', value); + }; o.modalonly = true; o = s.taboption('advanced', form.Flag, "use_acme_server",