Skip to content

Commit

Permalink
fix up serial generation
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Nov 9, 2017
1 parent 9d4fa69 commit 5b62d74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/install-authority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ async function addToLinuxTrustStores (commonName: string, rootCertPath: string):
// even try it - we just bail out to the GUI.
async function addToWindowsTrustStores (rootCertPath: string): Promise<void> {
// IE, Chrome, system utils
execSync(`certutil -addstore -user root ${rootCertPath}`);
try {
execSync(`certutil -addstore -user root ${rootCertPath}`);
}
catch (e) {}
// Firefox (don't even try NSS certutil, no easy install for Windows)
await openCertificateInFirefox(rootCertPath, 'start firefox');
}
Expand Down Expand Up @@ -142,4 +145,4 @@ function lookupOrInstallCertutil (): string | void {
execSync('sudo apt install libnss3-tools');
return execSync('which certutil').toString().trim();
}
}
}
3 changes: 1 addition & 2 deletions src/openssl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function normalizeLinebreaks (str) {
return str.replace(newline, linebreak);
}


const opensslConfTemplate = ({ commonName, databasePath, serialPath }: OpensslTemplateOpts) => `[ ca ]
# \`man ca\`
default_ca = CA_default
Expand Down Expand Up @@ -126,7 +125,7 @@ export function generateOpensslConf (commonName: string) {
const opensslConf = opensslConfTemplate({ commonName, databasePath, serialPath });
fs.writeFileSync(opensslConfPath, normalizeLinebreaks(opensslConf));
fs.writeFileSync(databasePath, '');
fs.writeFileSync(serialPath, '01');
fs.writeFileSync(serialPath, Math.round(Math.random() * 16 ** 10).toString(16));
return opensslConfPath;
}

Expand Down

0 comments on commit 5b62d74

Please sign in to comment.