From 01cdc0e91b5bf03f12e1b25b4129e3cde927987c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 4 May 2018 10:45:22 +0000 Subject: [PATCH] use SAN only when requested --- csr.js | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/csr.js b/csr.js index 8fd57bf..4543773 100644 --- a/csr.js +++ b/csr.js @@ -127,28 +127,33 @@ function createPkcs10Csr(domainKeypair, domains) { ] }); - var altNames = new org.pkijs.simpl.GENERAL_NAMES({ - names: [ - new org.pkijs.simpl.GENERAL_NAME({ - NameType: 2, - Name: domains.join(', DNS:') //"domain1.com, DNS:domain2.com, DNS:domain3.com" - }) - ] - }); + function addSan() { + var altNames = new org.pkijs.simpl.GENERAL_NAMES({ + names: [ + new org.pkijs.simpl.GENERAL_NAME({ + NameType: 2, + Name: domains.join(', DNS:') //"domain1.com, DNS:domain2.com, DNS:domain3.com" + }) + ] + }); - extensions.extensions_array.push(new org.pkijs.simpl.EXTENSION({ - extnID: "2.5.29.17", // subjectAltName - critical: false, - extnValue: altNames.toSchema().toBER(false) - })); + extensions.extensions_array.push(new org.pkijs.simpl.EXTENSION({ + extnID: "2.5.29.17", // subjectAltName + critical: false, + extnValue: altNames.toSchema().toBER(false) + })); - var attribute = new org.pkijs.simpl.ATTRIBUTE({ - type: "1.2.840.113549.1.9.14", // pkcs-9-at-extensionRequest - values: [extensions.toSchema()] - }); + var attribute = new org.pkijs.simpl.ATTRIBUTE({ + type: "1.2.840.113549.1.9.14", // pkcs-9-at-extensionRequest + values: [extensions.toSchema()] + }); - pkcs10_simpl.attributes.push(attribute); + pkcs10_simpl.attributes.push(attribute); + } + if (domains.length) { + addSan(); + } }); // #endregion @@ -183,4 +188,4 @@ CSR.generate = function (options) { return createPkcs10Csr(options.keypair, options.domains); }; -}(window)); +}(window)); \ No newline at end of file