Merge pull request #21336 from owncloud/system-root-certs
Allow admins to add system wide root certificatesremotes/origin/app-styles-content-list
commit
eac5d9fb3a
@ -0,0 +1,69 @@
|
||||
$(document).ready(function () {
|
||||
var type = $('#sslCertificate').data('type');
|
||||
$('#sslCertificate').on('click', 'td.remove', function () {
|
||||
var row = $(this).parent();
|
||||
$.ajax(OC.generateUrl('settings/' + type + '/certificate/{certificate}', {certificate: row.data('name')}), {
|
||||
type: 'DELETE'
|
||||
});
|
||||
row.remove();
|
||||
|
||||
if ($('#sslCertificate > tbody > tr').length === 0) {
|
||||
$('#sslCertificate').hide();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$('#sslCertificate tr > td').tipsy({gravity: 'n', live: true});
|
||||
|
||||
$('#rootcert_import').fileupload({
|
||||
submit: function (e, data) {
|
||||
data.formData = _.extend(data.formData || {}, {
|
||||
requesttoken: OC.requestToken
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
if (typeof data === 'string') {
|
||||
data = $.parseJSON(data);
|
||||
} else if (data && data.length) {
|
||||
// fetch response from iframe
|
||||
data = $.parseJSON(data[0].body.innerText);
|
||||
}
|
||||
if (!data || typeof(data) === 'string') {
|
||||
// IE8 iframe workaround comes here instead of fail()
|
||||
OC.Notification.showTemporary(
|
||||
t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.'));
|
||||
return;
|
||||
}
|
||||
var issueDate = new Date(data.validFrom * 1000);
|
||||
var expireDate = new Date(data.validTill * 1000);
|
||||
var now = new Date();
|
||||
var isExpired = !(issueDate <= now && now <= expireDate);
|
||||
|
||||
var row = $('<tr/>');
|
||||
row.data('name', data.name);
|
||||
row.addClass(isExpired ? 'expired' : 'valid');
|
||||
row.append($('<td/>').attr('title', data.organization).text(data.commonName));
|
||||
row.append($('<td/>').attr('title', t('core,', 'Valid until {date}', {date: data.validTillString}))
|
||||
.text(data.validTillString));
|
||||
row.append($('<td/>').attr('title', data.issuerOrganization).text(data.issuer));
|
||||
row.append($('<td/>').addClass('remove').append(
|
||||
$('<img/>').attr({
|
||||
alt: t('core', 'Delete'),
|
||||
title: t('core', 'Delete'),
|
||||
src: OC.imagePath('core', 'actions/delete.svg')
|
||||
}).addClass('action')
|
||||
));
|
||||
|
||||
$('#sslCertificate tbody').append(row);
|
||||
$('#sslCertificate').show();
|
||||
},
|
||||
fail: function () {
|
||||
OC.Notification.showTemporary(
|
||||
t('settings', 'An error occurred. Please upload an ASCII-encoded PEM certificate.'));
|
||||
}
|
||||
});
|
||||
|
||||
if ($('#sslCertificate > tbody > tr').length === 0) {
|
||||
$('#sslCertificate').hide();
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,44 @@
|
||||
<div class="section">
|
||||
<h2><?php p($l->t('SSL Root Certificates')); ?></h2>
|
||||
<table id="sslCertificate" class="grid" data-type="<?php p($_['type']); ?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php p($l->t('Common Name')); ?></th>
|
||||
<th><?php p($l->t('Valid until')); ?></th>
|
||||
<th><?php p($l->t('Issued By')); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($_['certs'] as $rootCert): /**@var \OCP\ICertificate $rootCert */ ?>
|
||||
<tr class="<?php echo ($rootCert->isExpired()) ? 'expired' : 'valid' ?>"
|
||||
data-name="<?php p($rootCert->getName()) ?>">
|
||||
<td class="rootCert"
|
||||
title="<?php p($rootCert->getOrganization()) ?>">
|
||||
<?php p($rootCert->getCommonName()) ?>
|
||||
</td>
|
||||
<td title="<?php p($l->t('Valid until %s', $l->l('date', $rootCert->getExpireDate()))) ?>">
|
||||
<?php echo $l->l('date', $rootCert->getExpireDate()) ?>
|
||||
</td>
|
||||
<td title="<?php p($rootCert->getIssuerOrganization()) ?>">
|
||||
<?php p($rootCert->getIssuerName()) ?>
|
||||
</td>
|
||||
<td <?php if ($rootCert != ''): ?>class="remove"
|
||||
<?php else: ?>style="visibility:hidden;"
|
||||
<?php endif; ?>><img alt="<?php p($l->t('Delete')); ?>"
|
||||
title="<?php p($l->t('Delete')); ?>"
|
||||
class="svg action"
|
||||
src="<?php print_unescaped(image_path('core', 'actions/delete.svg')); ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<form class="uploadButton" method="post"
|
||||
action="<?php p($_['urlGenerator']->linkToRoute($_['uploadRoute'])); ?>"
|
||||
target="certUploadFrame">
|
||||
<label for="rootcert_import" class="inlineblock button"
|
||||
id="rootcert_import_button"><?php p($l->t('Import root certificate')); ?></label>
|
||||
<input type="file" id="rootcert_import" name="rootcert_import"
|
||||
class="hiddenuploadfield">
|
||||
</form>
|
||||
</div>
|
||||
Loading…
Reference in New Issue