Added code to automatically add the common name as a DNS name while creating a certificate.

This commit is contained in:
Kush Bavishi 2019-05-31 14:08:28 -07:00
parent 28b216273d
commit 45231c2423
2 changed files with 22 additions and 0 deletions

View File

@ -33,6 +33,8 @@
uib-tooltip="If you need a certificate with multiple domains enter your primary domain here and the rest under 'Subject Alternate Names' by clicking 'More Options'"
ng-model="certificate.commonName" placeholder="Common Name" class="form-control"
ng-maxlength="64"
ng-blur="certificate.attachCommonName()"
ng-focus="certificate.removeCommonName()"
required/>
<p ng-show="trackingForm.commonName.$invalid && !trackingForm.commonName.$pristine" class="help-block">

View File

@ -18,6 +18,26 @@ angular.module('lemur')
this.authority = authority;
this.authority.maxDate = moment(this.authority.notAfter).subtract(1, 'days').format('YYYY/MM/DD');
},
attachCommonName: function () {
if (this.extensions === undefined) {
this.extensions = {};
}
if (this.extensions.subAltNames === undefined) {
this.extensions.subAltNames = {'names': []};
}
if (angular.isString(this.commonName)) {
this.extensions.subAltNames.names.unshift({'nameType': 'DNSName', 'value': this.commonName});
}
},
removeCommonName: function () {
if (angular.isDefined(this.extensions) && angular.isDefined(this.extensions.subAltNames)) {
if (angular.equals(this.extensions.subAltNames.names[0].value, this.commonName)) {
this.extensions.subAltNames.names.shift();
}
}
},
attachSubAltName: function () {
if (this.extensions === undefined) {
this.extensions = {};