generate new codesign-cert if cert value changes #6999
Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
Simon Smith committed
May 18, 2025 at 16:24 UTC
0feaec0d6b9a96f7146f2bf6b489991dc195d67e
1 file changed
+6
-3
certoperations.js
+6
-3
@@ -1000,6 +1000,7 @@ module.exports.CertificateOperations = function (parent) {
1000
var organization = null;
1001
var forceWebCertGen = 0;
1002
var forceMpsCertGen = 0;
1003
+ var forceCodeCertGen = 0;
1004
if (certargs != undefined) {
1005
var xargs = certargs.split(',');
1006
if (xargs.length > 0) { commonName = xargs[0]; }
@@ -1025,6 +1026,7 @@ module.exports.CertificateOperations = function (parent) {
1026
r.CommonName = obj.getCertificateCommonName(r.web.cert);
1027
r.CommonNames = obj.getCertificateAltNames(r.web.cert);
1028
r.RootName = obj.getCertificateCommonName(r.root.cert);
1029
+ r.CodeCertName = obj.getCertificateCommonName(r.codesign.cert);
1030
1031
// If the "cert" name is not set, try to use the certificate CN instead (ok if the certificate is not wildcard).
1032
if (commonName == 'un-configured') {
@@ -1085,10 +1087,11 @@ module.exports.CertificateOperations = function (parent) {
1087
// Check if we have correct certificates.
1088
if (obj.compareCertificateNames(r.CommonNames, commonName) == false) { console.log("Error: " + commonName + " does not match name in TLS certificate: " + r.CommonNames.join(', ')); forceWebCertGen = 1; } else { r.CommonName = commonName; }
1089
if (r.AmtMpsName != mpsCommonName) { forceMpsCertGen = 1; }
1088
- if (args.keepcerts == true) { forceWebCertGen = 0; forceMpsCertGen = 0; r.CommonName = commonName; }
1090
+ if (r.CodeCertName != commonName) { forceCodeCertGen = 1; }
1091
+ if (args.keepcerts == true) { forceWebCertGen = 0; forceMpsCertGen = 0; forceCodeCertGen = 0; r.CommonName = commonName; }
1092
1093
// If the certificates matches what we want, use them.
1091
- if ((forceWebCertGen == 0) && (forceMpsCertGen == 0)) {
1094
+ if ((forceWebCertGen == 0) && (forceMpsCertGen == 0) && (forceCodeCertGen == 0)) {
1095
if (func !== null) { func(r); }
1096
return r;
1097
}
@@ -1185,7 +1188,7 @@ module.exports.CertificateOperations = function (parent) {
1188
1189
// If the code signing certificate does not exist, create one
1190
var codesignCertAndKey, codesignCertificate, codesignPrivateKey;
1188
- if (r.codesign == null) {
1191
+ if ((r.codesign == null) || (forceCodeCertGen === 1)) {
1192
console.log("Generating code signing certificate...");
1193
codesignCertAndKey = obj.IssueWebServerCertificate(rootCertAndKey, true, commonName, country, organization, { codeSign: true }, strongCertificate);
1194
codesignCertificate = obj.pki.certificateToPem(codesignCertAndKey.cert);