fix(xo-server/https): ask for passphrase (#2963)

Fixes #2962
This commit is contained in:
Julien Fontanet 2018-05-18 15:05:49 +02:00 committed by GitHub
parent 005a9fdc01
commit c6ae969a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import has from 'lodash/has'
import helmet from 'helmet' import helmet from 'helmet'
import includes from 'lodash/includes' import includes from 'lodash/includes'
import proxyConsole from './proxy-console' import proxyConsole from './proxy-console'
import pw from 'pw'
import serveStatic from 'serve-static' import serveStatic from 'serve-static'
import startsWith from 'lodash/startsWith' import startsWith from 'lodash/startsWith'
import stoppable from 'stoppable' import stoppable from 'stoppable'
@ -311,6 +312,13 @@ async function makeWebServerListen (
) { ) {
if (cert && key) { if (cert && key) {
;[opts.cert, opts.key] = await Promise.all([readFile(cert), readFile(key)]) ;[opts.cert, opts.key] = await Promise.all([readFile(cert), readFile(key)])
if (opts.key.includes('ENCRYPTED')) {
opts.passphrase = await new Promise(resolve => {
console.log('Encrypted key %s', key)
process.stdout.write(`Enter pass phrase: `)
pw(resolve)
})
}
} }
try { try {
const niceAddress = await webServer.listen(opts) const niceAddress = await webServer.listen(opts)