Comparing version 0.1.0 to 0.2.0
@@ -5,3 +5,13 @@ # Change Log | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/davewasmer/devcert/compare/v0.1.0...v0.2.0) (2017-03-30) | ||
### Features | ||
* improve Readme, return node.createServer compatible object, improve error messaging ([b760220](https://github.com/davewasmer/devcert/commit/b760220)) | ||
<a name="0.1.0"></a> | ||
# 0.1.0 (2017-03-29) |
{ | ||
"name": "devcert", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Generate trusted local SSL/TLS certificates for local SSL development", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -31,3 +31,3 @@ import { | ||
} | ||
const configPath = path.join.bind(path, configDir); | ||
const configPath: (...pathSegments: string[]) => string = path.join.bind(path, configDir); | ||
@@ -42,7 +42,2 @@ const opensslConfPath = path.join(__dirname, '..', 'openssl.conf'); | ||
interface Certificate { | ||
key: string; | ||
cert: string; | ||
} | ||
export default async function devcert(appName: string, options: Options = {}) { | ||
@@ -58,15 +53,19 @@ | ||
if (!existsSync(configPath('devcert-ca-root.key'))) { | ||
let appKeyPath = configPath(`${ appName }.key`); | ||
let appCertPath = configPath(`${ appName }.crt`); | ||
if (!existsSync(rootKeyPath)) { | ||
await installCertificateAuthority(options.installCertutil); | ||
} | ||
// Load our root CA and sign a new app cert with it. | ||
let appKeyPath = generateKey(appName); | ||
let appCertificatePath = generateSignedCertificate(appName, appKeyPath); | ||
if (!existsSync(configPath(`${ appName }.key`))) { | ||
generateKey(appName); | ||
generateSignedCertificate(appName, appKeyPath); | ||
} | ||
return { | ||
keyPath: appKeyPath, | ||
certificatePath: appCertificatePath, | ||
certPath: appCertPath, | ||
key: readFileSync(appKeyPath), | ||
certificate: readFileSync(appCertificatePath) | ||
cert: readFileSync(appCertPath) | ||
}; | ||
@@ -78,3 +77,3 @@ | ||
// us to minimize the need for elevated permissions while still allowing for per-app certificates. | ||
async function installCertificateAuthority(installCertutil: boolean) { | ||
async function installCertificateAuthority(installCertutil: boolean): Promise<void> { | ||
let rootKeyPath = generateKey('devcert-ca-root'); | ||
@@ -86,11 +85,10 @@ execSync(`openssl req -config ${ opensslConfPath } -key ${ rootKeyPath } -out ${ rootCertPath } -new -subj '/CN=devcert' -x509 -days 7000 -extensions v3_ca`); | ||
// Generate a cryptographic key, used to sign certificates or certificate signing requests. | ||
function generateKey(name: string): string { | ||
function generateKey(name: string): void { | ||
let filename = configPath(`${ name }.key`); | ||
execSync(`openssl genrsa -out ${ filename } 2048`); | ||
chmodSync(filename, 400); | ||
return filename; | ||
} | ||
// Generate a certificate signed by the devcert root CA | ||
function generateSignedCertificate(name: string, keyPath: string): string { | ||
function generateSignedCertificate(name: string, keyPath: string): void { | ||
let csrFile = configPath(`${ name }.csr`) | ||
@@ -100,3 +98,2 @@ execSync(`openssl req -config ${ opensslConfPath } -subj '/CN=${ name }' -key ${ keyPath } -out ${ csrFile } -new`); | ||
execSync(`openssl ca -config ${ opensslConfPath } -in ${ csrFile } -out ${ certPath } -keyfile ${ rootKeyPath } -cert ${ rootCertPath } -notext -md sha256 -days 7000 -extensions server_cert`) | ||
return certPath; | ||
} | ||
@@ -132,5 +129,7 @@ | ||
// Chrome | ||
// No try..catch, since there's no alternative here. Chrome won't prompt to add a cert to the | ||
// store if opened as a URL | ||
addCertificateToNSSCertDB('~/.pki/nssdb', installCertutil); | ||
try { | ||
addCertificateToNSSCertDB('~/.pki/nssdb', installCertutil); | ||
} catch (e) { | ||
console.warn('WARNING: Because you did not pass in `installCertutil` to devcert, we are unable to update Chrome to respect generated development certificates. The certificates will work, but Chrome will continue to warn you that they are untrusted.'); | ||
} | ||
@@ -163,3 +162,3 @@ // Windows | ||
// Launch a web server and open the root cert in Firefox. Useful for when certutil isn't available | ||
async function openCertificateInFirefox(firefoxPath: string) { | ||
async function openCertificateInFirefox(firefoxPath: string): Promise<void> { | ||
let port = await getPort(); | ||
@@ -173,2 +172,4 @@ let server = http.createServer((req, res) => { | ||
await new Promise((resolve) => { | ||
console.log('Unable to automatically install SSL certificate - please follow the prompts in Firefox to trust the root certificate'); | ||
console.log('See https://github.com/davewasmer/devcert#how-it-works for more details'); | ||
process.stdin.resume(); | ||
@@ -175,0 +176,0 @@ process.stdin.on('data', resolve); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
52400
9
192
0
80