diff --git a/index.js b/index.js index 7146ed9..a1ef681 100644 --- a/index.js +++ b/index.js @@ -33,13 +33,20 @@ function createCert() { cert.serialNumber = '01'; cert.validity.notBefore = new Date(); cert.validity.notAfter = new Date(); - cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 20); + cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 20); + + const altNames = ["127.0.0.1"]; + + for(let i=1;i<255;i++) { + altNames.push({ type: 7, ip: `192.168.0.${i}`}); + } // use your own attributes here, or supply a csr (check the docs) var attrs = [{ name: 'commonName', value: 'dev.web-atoms.in' - }, { + }, + { name: 'countryName', value: 'IN' }, { @@ -58,6 +65,10 @@ function createCert() { // here we set subject and issuer as the same one cert.setSubject(attrs); + cert.setExtensions([{ + name: "subjectAltName", + altnames + }]) cert.setIssuer(attrs); // the actual certificate signing