Skip to content

Commit

Permalink
luci-app-acme: Migrate old keylength to key_type
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Ponomarev <[email protected]>
  • Loading branch information
stokito committed Jun 7, 2023
1 parent c09f5a7 commit 62187b9
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
'require form';
'require fs';
'require uci';
'require view';

return view.extend({
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 62187b9

Please sign in to comment.