Skip to content

Commit

Permalink
Added certificate names
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Jun 19, 2024
1 parent e58c35f commit 7a756a0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}, {
Expand All @@ -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
Expand Down

0 comments on commit 7a756a0

Please sign in to comment.