1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added new rootCertCommonName option is config.json setting to change the default root common name when generating the root certificate, #4221

This commit is contained in:
Ylian Saint-Hilaire 2022-07-05 13:44:24 -07:00
parent f2c5f4efdb
commit acd281c990
2 changed files with 9 additions and 2 deletions

View file

@ -1006,7 +1006,13 @@ module.exports.CertificateOperations = function (parent) {
if (r.root == null) {
// If the root certificate does not exist, create one
console.log("Generating root certificate...");
rootCertAndKey = obj.GenerateRootCertificate(true, 'MeshCentralRoot', null, null, strongCertificate);
if (typeof args.rootcertcommonname == 'string') {
// If a root certificate common name is specified, use it.
rootCertAndKey = obj.GenerateRootCertificate(false, args.rootcertcommonname, null, null, strongCertificate);
} else {
// A root certificate common name is not specified, use the default one.
rootCertAndKey = obj.GenerateRootCertificate(true, 'MeshCentralRoot', null, null, strongCertificate);
}
rootCertificate = obj.pki.certificateToPem(rootCertAndKey.cert);
rootPrivateKey = obj.pki.privateKeyToPem(rootCertAndKey.key);
obj.fs.writeFileSync(parent.getConfigFilePath('root-cert-public.crt'), rootCertificate);