From c15a2c62d11e2402460a21db7ca5a76dee17269b Mon Sep 17 00:00:00 2001 From: sayali Date: Mon, 3 Aug 2020 19:22:13 -0700 Subject: [PATCH 1/3] Honor selected algorithm during certificate cloning --- .../static/app/angular/certificates/certificate/certificate.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lemur/static/app/angular/certificates/certificate/certificate.js b/lemur/static/app/angular/certificates/certificate/certificate.js index 21f61f22..83b0cfe8 100644 --- a/lemur/static/app/angular/certificates/certificate/certificate.js +++ b/lemur/static/app/angular/certificates/certificate/certificate.js @@ -212,12 +212,14 @@ angular.module('lemur') }) .controller('CertificateCloneController', function ($scope, $uibModalInstance, CertificateApi, CertificateService, DestinationService, AuthorityService, AuthorityApi, PluginService, MomentService, WizardHandler, LemurRestangular, NotificationService, toaster, editId) { + $scope.certificate = LemurRestangular.restangularizeElement(null, {}, 'certificates'); 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; + $scope.certificate.keyType = 'RSA2048'; // default algo to show during clone CertificateService.getDefaults($scope.certificate); }); From c3d8501401ef2d59af115055c4ab3046acc64811 Mon Sep 17 00:00:00 2001 From: sayali Date: Mon, 3 Aug 2020 19:23:24 -0700 Subject: [PATCH 2/3] Do not inherit replacement info during cert clone --- .../static/app/angular/certificates/certificate/certificate.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lemur/static/app/angular/certificates/certificate/certificate.js b/lemur/static/app/angular/certificates/certificate/certificate.js index 83b0cfe8..bb4e7db6 100644 --- a/lemur/static/app/angular/certificates/certificate/certificate.js +++ b/lemur/static/app/angular/certificates/certificate/certificate.js @@ -215,11 +215,14 @@ angular.module('lemur') $scope.certificate = LemurRestangular.restangularizeElement(null, {}, 'certificates'); CertificateApi.get(editId).then(function (certificate) { $scope.certificate = certificate; + // prepare the certificate for cloning $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; $scope.certificate.keyType = 'RSA2048'; // default algo to show during clone + $scope.certificate.replacedBy = []; // should not clone 'replaced by' info + $scope.certificate.removeReplaces(); // should not clone 'replacement cert' info CertificateService.getDefaults($scope.certificate); }); From 817a4c3d9081cf7d30056328c45d677b92422c2c Mon Sep 17 00:00:00 2001 From: sayali Date: Mon, 3 Aug 2020 19:24:06 -0700 Subject: [PATCH 3/3] Modified cert description to have cert id being cloned --- lemur/static/app/angular/certificates/certificate/certificate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lemur/static/app/angular/certificates/certificate/certificate.js b/lemur/static/app/angular/certificates/certificate/certificate.js index bb4e7db6..155658e6 100644 --- a/lemur/static/app/angular/certificates/certificate/certificate.js +++ b/lemur/static/app/angular/certificates/certificate/certificate.js @@ -221,6 +221,7 @@ angular.module('lemur') $scope.certificate.validityStart = null; $scope.certificate.validityEnd = null; $scope.certificate.keyType = 'RSA2048'; // default algo to show during clone + $scope.certificate.description = 'Cloning from cert ID ' + editId; $scope.certificate.replacedBy = []; // should not clone 'replaced by' info $scope.certificate.removeReplaces(); // should not clone 'replacement cert' info CertificateService.getDefaults($scope.certificate);