mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
System: Trust - add descriptions on download, closes https://github.com/opnsense/core/pull/7932
This commit is contained in:
parent
b5ca261e18
commit
58dee6f789
@ -233,6 +233,7 @@ class CaController extends ApiMutableModelControllerBase
|
||||
$result = ['status' => 'failed'];
|
||||
if ($this->request->isPost() && !empty($uuid)) {
|
||||
$node = $this->getModel()->getNodeByReference('ca.' . $uuid);
|
||||
$result['descr'] = $node !== null ? (string)$node->descr : '';
|
||||
if ($node === null || empty((string)$node->crt_payload)) {
|
||||
$result['error'] = gettext('Misssing certificate');
|
||||
} elseif ($type == 'crt') {
|
||||
|
||||
@ -275,6 +275,7 @@ class CertController extends ApiMutableModelControllerBase
|
||||
$result = ['status' => 'failed'];
|
||||
if ($this->request->isPost() && !empty($uuid)) {
|
||||
$node = $this->getModel()->getNodeByReference('cert.' . $uuid);
|
||||
$result['descr'] = $node !== null ? (string)$node->descr : '';
|
||||
if ($node === null || empty((string)$node->crt_payload)) {
|
||||
$result['error'] = gettext('Misssing certificate');
|
||||
} elseif ($type == 'crt') {
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
'/api/trust/ca/generate_file/'+uuid+'/'+$type.val(),
|
||||
params,
|
||||
function(data, status) {
|
||||
download_content(data.payload, $type.val() + '.pem', 'application/octet-stream');
|
||||
download_content(data.payload, data.descr + '_' + $type.val() + '.pem', 'application/octet-stream');
|
||||
}
|
||||
)
|
||||
dialogItself.close();
|
||||
|
||||
@ -104,15 +104,15 @@
|
||||
params,
|
||||
function(data, status) {
|
||||
let payload = null;
|
||||
let filename = null;
|
||||
let filename = data.descr + '_' ;
|
||||
let mediatype = 'application/octet-stream';
|
||||
if (data.payload_b64) {
|
||||
mediatype += ';base64';
|
||||
payload = data.payload_b64;
|
||||
filename = 'cert.p12';
|
||||
filename += 'cert.p12';
|
||||
} else if (data.payload) {
|
||||
payload = data.payload;
|
||||
filename = $type.val() + '.pem';
|
||||
filename += $type.val() + '.pem';
|
||||
}
|
||||
if (payload !== null) {
|
||||
download_content(payload, filename, mediatype);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user