From 9486292d42c2bf8bd6a3495672b6174a9a438050 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Mon, 7 Aug 2023 22:03:08 +0300 Subject: [PATCH] luci-app-acme: Migrate old keylength to key_type Signed-off-by: Sergey Ponomarev --- .../htdocs/luci-static/resources/view/acme.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 66735b5d85..9dd0e23ff7 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({ @@ -64,6 +65,26 @@ return view.extend({ o.rmempty = false; o.optional = true; o.modalonly = true; + o.cfgvalue = function(section_id, set_value) { + var keylength = uci.get('acme', section_id, 'keylength'); + if (keylength) { + // migrate the old keylength to a 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.unset('acme', section_id, 'keylength'); + uci.set('acme', section_id, 'key_type', value); + }; o = s.taboption('general', form.DynamicList, "domains", _("Domain names"), _("Domain names to include in the certificate. " + -- 2.30.2