luci-app-acme: List of certificates
Add Certificates section to help users to see issued certificates and path to them. Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
This commit is contained in:
parent
bebad8f7f8
commit
e344960c55
2 changed files with 47 additions and 4 deletions
|
@ -5,7 +5,19 @@
|
||||||
'require view';
|
'require view';
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
render: function (stats) {
|
load: function() {
|
||||||
|
return L.resolveDefault(fs.list('/etc/ssl/acme/'), []).then(function(entries) {
|
||||||
|
var certs = [];
|
||||||
|
for (var i = 0; i < entries.length; i++) {
|
||||||
|
if (entries[i].type == 'file' && entries[i].name.match(/\.key$/)) {
|
||||||
|
certs.push(entries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return certs;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function (certs) {
|
||||||
let wikiUrl = 'https://github.com/acmesh-official/acme.sh/wiki/';
|
let wikiUrl = 'https://github.com/acmesh-official/acme.sh/wiki/';
|
||||||
var wikiInstructionUrl = wikiUrl + 'dnsapi';
|
var wikiInstructionUrl = wikiUrl + 'dnsapi';
|
||||||
var m, s, o;
|
var m, s, o;
|
||||||
|
@ -512,7 +524,12 @@ return view.extend({
|
||||||
o.datatype = 'uinteger';
|
o.datatype = 'uinteger';
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
|
||||||
return m.render()
|
|
||||||
|
s = m.section(form.GridSection, '_certificates');
|
||||||
|
|
||||||
|
s.render = L.bind(_renderCerts, this, certs);
|
||||||
|
|
||||||
|
return m.render();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -560,3 +577,30 @@ function _extractParamValue(paramsKeyVals, paramName) {
|
||||||
function _handleCheckService(c, event, curVal, newVal) {
|
function _handleCheckService(c, event, curVal, newVal) {
|
||||||
document.getElementById('wikiInstructionUrl').href = 'https://github.com/acmesh-official/acme.sh/wiki/dnsapi#' + newVal;
|
document.getElementById('wikiInstructionUrl').href = 'https://github.com/acmesh-official/acme.sh/wiki/dnsapi#' + newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _renderCerts(certs) {
|
||||||
|
var table = E('table', {'class': 'table cbi-section-table', 'id': 'certificates_table'}, [
|
||||||
|
E('tr', {'class': 'tr table-titles'}, [
|
||||||
|
E('th', {'class': 'th'}, _('Main Domain')),
|
||||||
|
E('th', {'class': 'th'}, _('Private Key')),
|
||||||
|
E('th', {'class': 'th'}, _('Public Certificate')),
|
||||||
|
E('th', {'class': 'th'}, _('Issued on')),
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
var rows = certs.map(function (cert) {
|
||||||
|
let domain = cert.name.substring(0, cert.name.length - 4);
|
||||||
|
let issueDate = new Date(cert.mtime * 1000).toLocaleDateString();
|
||||||
|
return [
|
||||||
|
domain,
|
||||||
|
'/etc/ssl/acme/' + domain + '.key',
|
||||||
|
'/etc/ssl/acme/' + domain + '.fullchain.crt',
|
||||||
|
issueDate,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
cbi_update_table(table, rows);
|
||||||
|
|
||||||
|
return E('div', {'class': 'cbi-section cbi-tblsection'}, [
|
||||||
|
E('h3', _('Certificates')), table]);
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
"description": "Grant UCI access for luci-app-acme",
|
"description": "Grant UCI access for luci-app-acme",
|
||||||
"read": {
|
"read": {
|
||||||
"file": {
|
"file": {
|
||||||
"/usr/sbin/nginx": [ "read" ],
|
"/etc/ssl/acme": [ "list" ]
|
||||||
"/usr/sbin/uhttpd": [ "read" ]
|
|
||||||
},
|
},
|
||||||
"uci": [ "acme" ]
|
"uci": [ "acme" ]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue