Skip to content

Commit

Permalink
fix: use selfsigned instead of devcert for certificate generation (#1650
Browse files Browse the repository at this point in the history
)

Fixes #1649
  • Loading branch information
KEGustafsson authored Nov 2, 2023
1 parent 5abe63f commit 2761003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
20 changes: 11 additions & 9 deletions src/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2761003

Please sign in to comment.