TobiasMelen / next-dev-https

Next Development server Https/QR support
MIT License
25 stars 4 forks source link

Nodejs 18 required #2

Closed emulienfou closed 1 year ago

emulienfou commented 1 year ago

I may be wrong but it seems Nodejs 18 is the minimum required version to make this package work correctly!

With Nodejs 16 I got the next error message:

/usr/local/bin/yarn run dev
node:internal/tls/secure-context:65
    context.setCert(cert);
            ^

Error: error:0A00018F:SSL routines::ee key too small
    at node:internal/tls/secure-context:65:13
    at Array.forEach (<anonymous>)
    at setCerts (node:internal/tls/secure-context:63:3)
    at configSecureContext (node:internal/tls/secure-context:152:5)
    at Object.createSecureContext (node:_tls_common:117:3)
    at Server.setSecureContext (node:_tls_wrap:1346:27)
    at Server (node:_tls_wrap:1205:8)
    at new Server (node:https:69:3)
    at Object.createServer (node:https:105:10)
    at startServer (/app/node_modules/next-dev-https/src/server.js:229:18) {
  library: 'SSL routines',
  reason: 'ee key too small',
  code: 'ERR_SSL_EE_KEY_TOO_SMALL'
}

Process finished with exit code 1

You should probably update your package.json to add the minimum version of the engine like:

"engines": {
    "node": ">=18"
}

You could also specify that in the README file.

TobiasMelen commented 1 year ago

Thanks for reporting @emulienfou, will look into this when possible. My initial take is that it's weird that this diffs between node versions. It looks to me that this is a revocation from upstream (OpenSSL prob) from using the cert generated by selfsigned. We should probably change the cert generation params, it should be working on node 16.

Two questions which will speedup debugging: Which OS(linux, mac, windows) and version is triggering the issue? Have you validated that this works on the same machine with node 18 but not on 16?

emulienfou commented 1 year ago

Hi @TobiasMelen, I was running on Debian 11 with both latest versions of node J's 16 & 18. Switching from node 16 to 18 resolved the issue.

TobiasMelen commented 1 year ago

Hi @emulienfou I've increased encryption key size to 2048 and switched checksum algorithm to SHA256 which i hopes makes Debian happier to run the cert. Could you try installing this version, running it through node 16 on Debian to see if it's working better?

npm i next-dev-https@sha256
emulienfou commented 1 year ago

@TobiasMelen for reference purpose it was working fine on Node.js 16.20 but not on 16.15. After install next-dev-https@sha256 on Nodejs 16.15, it works like a charm now! Thanks for the fix

TobiasMelen commented 1 year ago

Thanks for reporting and testing, seems like selfsigned has quite lax certificate generation defaults, so it was good to bump them a bit. Change released in 2.0.1.