Add csr column to certificates field, as pending certificates have exposed the CSR already. This is required as generating CSR from existing certificate is will not include SANs due to OpenSSL bug: https://github.com/openssl/openssl/issues/6481 Change-Id: I9ea86c4f87067ee6d791d77dc1cce8f469cb2a22
375 lines
11 KiB
JavaScript
375 lines
11 KiB
JavaScript
'use strict';
|
|
|
|
angular.module('lemur')
|
|
.controller('CertificateExportController', function ($scope, $uibModalInstance, CertificateApi, CertificateService, PluginService, FileSaver, Blob, toaster, editId) {
|
|
CertificateApi.get(editId).then(function (certificate) {
|
|
$scope.certificate = certificate;
|
|
});
|
|
|
|
PluginService.getByType('export').then(function (plugins) {
|
|
$scope.plugins = plugins;
|
|
});
|
|
|
|
$scope.cancel = function () {
|
|
$uibModalInstance.dismiss('cancel');
|
|
};
|
|
|
|
$scope.save = function (certificate) {
|
|
CertificateService.export(certificate).then(
|
|
function (response) {
|
|
var byteCharacters = atob(response.data);
|
|
var byteArrays = [];
|
|
|
|
for (var offset = 0; offset < byteCharacters.length; offset += 512) {
|
|
var slice = byteCharacters.slice(offset, offset + 512);
|
|
|
|
var byteNumbers = new Array(slice.length);
|
|
for (var i = 0; i < slice.length; i++) {
|
|
byteNumbers[i] = slice.charCodeAt(i);
|
|
}
|
|
|
|
var byteArray = new Uint8Array(byteNumbers);
|
|
|
|
byteArrays.push(byteArray);
|
|
}
|
|
|
|
var blob = new Blob(byteArrays, {type: 'application/octet-stream'});
|
|
FileSaver.saveAs(blob, certificate.name + '.' + response.extension);
|
|
$scope.passphrase = response.passphrase;
|
|
},
|
|
function (response) {
|
|
toaster.pop({
|
|
type: 'error',
|
|
title: certificate.name,
|
|
body: 'lemur-bad-request',
|
|
bodyOutputType: 'directive',
|
|
directiveData: response.data,
|
|
timeout: 100000
|
|
});
|
|
});
|
|
};
|
|
})
|
|
.controller('CertificateEditController', function ($scope, $uibModalInstance, CertificateApi, CertificateService, DestinationService, NotificationService, toaster, editId) {
|
|
CertificateApi.get(editId).then(function (certificate) {
|
|
$scope.certificate = certificate;
|
|
});
|
|
|
|
$scope.cancel = function () {
|
|
$uibModalInstance.dismiss('cancel');
|
|
};
|
|
|
|
$scope.save = function (certificate) {
|
|
CertificateService.update(certificate).then(
|
|
function () {
|
|
toaster.pop({
|
|
type: 'success',
|
|
title: certificate.name,
|
|
body: 'Successfully updated!'
|
|
});
|
|
$uibModalInstance.close();
|
|
},
|
|
function (response) {
|
|
toaster.pop({
|
|
type: 'error',
|
|
title: certificate.name,
|
|
body: 'lemur-bad-request',
|
|
bodyOutputType: 'directive',
|
|
directiveData: response.data,
|
|
timeout: 100000
|
|
});
|
|
});
|
|
};
|
|
|
|
$scope.certificateService = CertificateService;
|
|
$scope.destinationService = DestinationService;
|
|
$scope.notificationService = NotificationService;
|
|
})
|
|
|
|
.controller('CertificateCreateController', function ($scope, $uibModalInstance, CertificateApi, CertificateService, DestinationService, AuthorityService, AuthorityApi, PluginService, MomentService, WizardHandler, LemurRestangular, NotificationService, toaster) {
|
|
$scope.certificate = LemurRestangular.restangularizeElement(null, {}, 'certificates');
|
|
// set the defaults
|
|
CertificateService.getDefaults($scope.certificate);
|
|
|
|
$scope.cancel = function () {
|
|
$uibModalInstance.dismiss('cancel');
|
|
};
|
|
|
|
$scope.getAuthoritiesByName = function (value) {
|
|
return AuthorityService.findActiveAuthorityByName(value).then(function (authorities) {
|
|
$scope.authorities = authorities;
|
|
});
|
|
};
|
|
|
|
$scope.dateOptions = {
|
|
formatYear: 'yy',
|
|
maxDate: new Date(2020, 5, 22),
|
|
minDate: new Date(),
|
|
startingDay: 1
|
|
};
|
|
|
|
|
|
$scope.open1 = function() {
|
|
$scope.popup1.opened = true;
|
|
};
|
|
|
|
$scope.open2 = function() {
|
|
$scope.popup2.opened = true;
|
|
};
|
|
|
|
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
|
|
$scope.format = $scope.formats[0];
|
|
$scope.altInputFormats = ['M!/d!/yyyy'];
|
|
|
|
$scope.popup1 = {
|
|
opened: false
|
|
};
|
|
|
|
$scope.popup2 = {
|
|
opened: false
|
|
};
|
|
|
|
$scope.clearDates = function () {
|
|
$scope.certificate.validityStart = null;
|
|
$scope.certificate.validityEnd = null;
|
|
$scope.certificate.validityYears = null;
|
|
};
|
|
|
|
CertificateService.getDnsProviders().then(function (providers) {
|
|
$scope.dnsProviders = providers;
|
|
}
|
|
);
|
|
|
|
$scope.create = function (certificate) {
|
|
WizardHandler.wizard().context.loading = true;
|
|
CertificateService.create(certificate).then(
|
|
function () {
|
|
toaster.pop({
|
|
type: 'success',
|
|
title: certificate.name,
|
|
body: 'Successfully created!'
|
|
});
|
|
$uibModalInstance.close();
|
|
},
|
|
function (response) {
|
|
toaster.pop({
|
|
type: 'error',
|
|
title: certificate.name,
|
|
body: 'lemur-bad-request',
|
|
bodyOutputType: 'directive',
|
|
directiveData: response.data,
|
|
timeout: 100000
|
|
});
|
|
|
|
WizardHandler.wizard().context.loading = false;
|
|
});
|
|
};
|
|
|
|
$scope.templates = [
|
|
{
|
|
'name': 'Client Certificate',
|
|
'description': '',
|
|
'extensions': {
|
|
'basicConstraints': {},
|
|
'keyUsage': {
|
|
'useDigitalSignature': true
|
|
},
|
|
'extendedKeyUsage': {
|
|
'useClientAuthentication': true
|
|
},
|
|
'subjectKeyIdentifier': {
|
|
'includeSKI': true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
'name': 'Server Certificate',
|
|
'description': '',
|
|
'extensions' : {
|
|
'basicConstraints': {},
|
|
'keyUsage': {
|
|
'useKeyEncipherment': true,
|
|
'useDigitalSignature': true
|
|
},
|
|
'extendedKeyUsage': {
|
|
'useServerAuthentication': true
|
|
},
|
|
'subjectKeyIdentifier': {
|
|
'includeSKI': true
|
|
}
|
|
}
|
|
}
|
|
];
|
|
|
|
|
|
PluginService.getByType('destination').then(function (plugins) {
|
|
$scope.plugins = plugins;
|
|
});
|
|
|
|
$scope.certificateService = CertificateService;
|
|
$scope.authorityService = AuthorityService;
|
|
$scope.destinationService = DestinationService;
|
|
$scope.notificationService = NotificationService;
|
|
})
|
|
|
|
.controller('CertificateCloneController', function ($scope, $uibModalInstance, CertificateApi, CertificateService, DestinationService, AuthorityService, AuthorityApi, PluginService, MomentService, WizardHandler, LemurRestangular, NotificationService, toaster, editId) {
|
|
CertificateApi.get(editId).then(function (certificate) {
|
|
$scope.certificate = certificate;
|
|
$scope.certificate.name = ''; // we should prefer the generated name
|
|
$scope.certificate.csr = null; // should not clone CSR in case other settings are changed in clone
|
|
$scope.certificate.validityStart = null;
|
|
$scope.certificate.validityEnd = null;
|
|
CertificateService.getDefaults($scope.certificate);
|
|
});
|
|
|
|
$scope.cancel = function () {
|
|
$uibModalInstance.dismiss('cancel');
|
|
};
|
|
|
|
$scope.getAuthoritiesByName = function (value) {
|
|
return AuthorityService.findAuthorityByName(value).then(function (authorities) {
|
|
$scope.authorities = authorities;
|
|
});
|
|
};
|
|
|
|
$scope.dateOptions = {
|
|
formatYear: 'yy',
|
|
maxDate: new Date(2020, 5, 22),
|
|
minDate: new Date(),
|
|
startingDay: 1
|
|
};
|
|
|
|
|
|
$scope.open1 = function() {
|
|
$scope.popup1.opened = true;
|
|
};
|
|
|
|
$scope.open2 = function() {
|
|
$scope.popup2.opened = true;
|
|
};
|
|
|
|
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
|
|
$scope.format = $scope.formats[0];
|
|
$scope.altInputFormats = ['M!/d!/yyyy'];
|
|
|
|
$scope.popup1 = {
|
|
opened: false
|
|
};
|
|
|
|
$scope.popup2 = {
|
|
opened: false
|
|
};
|
|
|
|
CertificateService.getDnsProviders().then(function (providers) {
|
|
$scope.dnsProviders = providers;
|
|
}
|
|
);
|
|
|
|
$scope.clearDates = function () {
|
|
$scope.certificate.validityStart = null;
|
|
$scope.certificate.validityEnd = null;
|
|
$scope.certificate.validityYears = null;
|
|
};
|
|
|
|
$scope.create = function (certificate) {
|
|
WizardHandler.wizard().context.loading = true;
|
|
CertificateService.create(certificate).then(
|
|
function () {
|
|
toaster.pop({
|
|
type: 'success',
|
|
title: certificate.name,
|
|
body: 'Successfully created!'
|
|
});
|
|
$uibModalInstance.close();
|
|
},
|
|
function (response) {
|
|
toaster.pop({
|
|
type: 'error',
|
|
title: certificate.name,
|
|
body: 'lemur-bad-request',
|
|
bodyOutputType: 'directive',
|
|
directiveData: response.data,
|
|
timeout: 100000
|
|
});
|
|
|
|
WizardHandler.wizard().context.loading = false;
|
|
});
|
|
};
|
|
|
|
$scope.templates = [
|
|
{
|
|
'name': 'Client Certificate',
|
|
'description': '',
|
|
'extensions': {
|
|
'basicConstraints': {},
|
|
'keyUsage': {
|
|
'useDigitalSignature': true
|
|
},
|
|
'extendedKeyUsage': {
|
|
'useClientAuthentication': true
|
|
},
|
|
'subjectKeyIdentifier': {
|
|
'includeSKI': true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
'name': 'Server Certificate',
|
|
'description': '',
|
|
'extensions' : {
|
|
'basicConstraints': {},
|
|
'keyUsage': {
|
|
'useKeyEncipherment': true,
|
|
'useDigitalSignature': true
|
|
},
|
|
'extendedKeyUsage': {
|
|
'useServerAuthentication': true
|
|
},
|
|
'subjectKeyIdentifier': {
|
|
'includeSKI': true
|
|
}
|
|
}
|
|
}
|
|
];
|
|
|
|
PluginService.getByType('destination').then(function (plugins) {
|
|
$scope.plugins = plugins;
|
|
});
|
|
|
|
$scope.certificateService = CertificateService;
|
|
$scope.authorityService = AuthorityService;
|
|
$scope.destinationService = DestinationService;
|
|
$scope.notificationService = NotificationService;
|
|
})
|
|
|
|
.controller('CertificateRevokeController', function ($scope, $uibModalInstance, CertificateApi, CertificateService, LemurRestangular, NotificationService, toaster, revokeId) {
|
|
CertificateApi.get(revokeId).then(function (certificate) {
|
|
$scope.certificate = certificate;
|
|
});
|
|
|
|
$scope.cancel = function () {
|
|
$uibModalInstance.dismiss('cancel');
|
|
};
|
|
|
|
$scope.revoke = function (certificate) {
|
|
CertificateService.revoke(certificate).then(
|
|
function () {
|
|
toaster.pop({
|
|
type: 'success',
|
|
title: certificate.name,
|
|
body: 'Successfully revoked!'
|
|
});
|
|
$uibModalInstance.close();
|
|
},
|
|
function (response) {
|
|
toaster.pop({
|
|
type: 'error',
|
|
title: certificate.name,
|
|
body: 'lemur-bad-request',
|
|
bodyOutputType: 'directive',
|
|
directiveData: response.data,
|
|
timeout: 100000
|
|
});
|
|
});
|
|
};
|
|
});
|