Skip to content

Commit

Permalink
Merge pull request #5 from RandomByte/cert-825-day-lifetime
Browse files Browse the repository at this point in the history
Limit CA and Cert lifetime to 825 days
  • Loading branch information
guybedford authored Dec 12, 2019
2 parents d0cebfa + bf6e1c5 commit 8dd4c96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/openssl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function generateKey (): string {
export function generateRootCertificate (commonName: string, opensslConfPath: string) {
const rootCertPath = tmpFile(`${commonName}.crt`);
const rootKeyPath = generateKey();
openssl(`req -config ${opensslConfPath} -key ${rootKeyPath} -out ${rootCertPath} -new -subj "/CN=${commonName}" -x509 -days 7000 -extensions v3_ca`);
openssl(`req -config ${opensslConfPath} -key ${rootKeyPath} -out ${rootCertPath} -new -subj "/CN=${commonName}" -x509 -days 825 -extensions v3_ca`);
return { rootKeyPath, rootCertPath };
}

Expand All @@ -154,7 +154,7 @@ export function generateSignedCertificate (commonName: string, opensslConfPath:
const caCertsDir = path.join(os.tmpdir(), Math.round(Math.random() * 36 ** 10).toString(36));
mkdirp.sync(caCertsDir);

openssl(`ca -config ${opensslConfPath} -in ${csrFile} -out ${certPath} -outdir ${caCertsDir} -keyfile ${rootKeyPath} -cert ${caPath} -notext -md sha256 -days 7000 -batch -extensions server_cert`)
openssl(`ca -config ${opensslConfPath} -in ${csrFile} -out ${certPath} -outdir ${caCertsDir} -keyfile ${rootKeyPath} -cert ${caPath} -notext -md sha256 -days 825 -batch -extensions server_cert`)

rimraf.sync(caCertsDir);

Expand Down

0 comments on commit 8dd4c96

Please sign in to comment.