ssl: Fix resolving path to builtin ssl certs if not overwritten

This commit is contained in:
Jonatan Nilsson 2021-10-14 10:09:59 +00:00
parent 035fb0d7d0
commit d7c544243c

View file

@ -1,4 +1,6 @@
import fs from 'fs' import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import Nconf from 'nconf-lite' import Nconf from 'nconf-lite'
const nconf = new Nconf() const nconf = new Nconf()
@ -27,6 +29,8 @@ if (fs.existsSync(filename)) {
nconf.file('main', nconf.get('config') || '../config.json'); nconf.file('main', nconf.get('config') || '../config.json');
} }
const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Default variables // Default variables
nconf.defaults({ nconf.defaults({
name: nconf.get('name') || 'spserver', name: nconf.get('name') || 'spserver',
@ -40,8 +44,8 @@ nconf.defaults({
level: 'info', level: 'info',
}, },
}, },
sslkey: 'key.pem', sslkey: path.resolve(path.join(__dirname, '../key.pem')),
sslcert: 'cert.pem', sslcert: path.resolve(path.join(__dirname, '../cert.pem')),
development: { development: {
port: 3001, port: 3001,
bunyan: { bunyan: {