diff --git a/lib/Server.js b/lib/Server.js index eecb6c71a7..c0e3ada678 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -13,6 +13,7 @@ const fs = require('fs'); const path = require('path'); const ip = require('ip'); +const tls = require('tls'); const url = require('url'); const http = require('http'); const https = require('https'); @@ -40,6 +41,16 @@ const createCertificate = require('./utils/createCertificate'); const validateOptions = require('schema-utils'); const schema = require('./options.json'); +// Workaround for node ^8.6.0, ^9.0.0 +// DEFAULT_ECDH_CURVE is default to prime256v1 in these version +// breaking connection when certificate is not signed with prime256v1 +// change it to auto allows OpenSSL to select the curve automatically +// See https://github.com/nodejs/node/issues/16196 for more infomation +const verMatch = process.version.match(/^v(\d+).(\d+)/); +if (verMatch && (+verMatch[1] === 9 || (+verMatch[1] === 8 && +verMatch[2] >= 6))) { + tls.DEFAULT_ECDH_CURVE = 'auto'; +} + const STATS = { all: false, hash: true,