diff --git a/package.json b/package.json index 21c42f5f3..6d8904637 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,6 @@ "cookie-parser": "^1.4.3", "cors": "^2.5.2", "debug": "^4.3.3", - "devcert": "^1.2.2", "dnssd2": "1.0.0", "errorhandler": "^1.3.0", "express": "^4.10.4", @@ -117,6 +116,7 @@ "ncp": "^2.0.0", "node-fetch": "^2.6.0", "primus": "^7.0.0", + "selfsigned": "^2.4.1", "semver": "^7.5.4", "split": "^1.0.0", "stat-mode": "^1.0.0", diff --git a/src/security.ts b/src/security.ts index fb45f0eaa..e63742647 100644 --- a/src/security.ts +++ b/src/security.ts @@ -27,7 +27,7 @@ import { } from 'fs' import _ from 'lodash' import path from 'path' -import { certificateFor } from 'devcert' +import { generate } from 'selfsigned' import { Mode } from 'stat-mode' import { WithConfig } from './app' import { createDebug } from './debug' @@ -356,18 +356,20 @@ export function createCertificateOptions( ) { const location = app.config.configPath ? app.config.configPath : './settings' debug(`Creating certificate files in ${location}`) - certificateFor(['localhost']) - .then(({ key, cert }) => { - writeFileSync(keyFile, key) + generate( + [{ name: 'commonName', value: 'localhost' }], + { days: 3650 }, + function (err, pems) { + writeFileSync(keyFile, pems.private) chmodSync(keyFile, '600') - writeFileSync(certFile, cert) + writeFileSync(certFile, pems.cert) chmodSync(certFile, '600') cb(null, { - key: key, - cert: cert + key: pems.private, + cert: pems.cert }) - }) - .catch(console.error) + } + ) } export function requestAccess(