uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.86k stars 569 forks source link

App construction failed on SSLApp #788

Closed x8BitRain closed 2 years ago

x8BitRain commented 2 years ago

Trying to create an SSLApp with cert and key but no matter where I put the cert (same level, folder above or below) and the key or how I name them it fails with Error: App construction failed.

If I remove the cert_file_name and key_file_name settings it launches just fine.

The code in question is basic, readFileSync doesn't work either:

image

The error:

image

Doesn't work in docker images like node:16-bullseye, node:16-buster or even on earlier versions of the natively on macos. Downgrading to version v20.7.0 doesn't work either.

EDIT: Soketi doesn't work either, same error.

This seems like a bug to me, any ideas? Thanks.

e3dio commented 2 years ago

This works for me: { key_file_name: './privkey.pem', cert_file_name: './fullchain.pem' } the ./ is not required for relative path, I just add it to clarify

x8BitRain commented 2 years ago

Does not work either, I tried Soketi and I get the same issue. Maybe related to this? https://github.com/uNetworking/uSockets/issues/131

Using --trace-uncaught doesn't reveal anything new.

e3dio commented 2 years ago

Either you are not linking to the correct pem files which needs private key and full chain, or I just confirmed the pem path you give is relative to where you called Node from and not relative to where the app JS file is, so if you called Node with node dir/to/app.js the pem path is not relative to app.js, it is relative to node so you would need pem path as dir/to/privkey.pem

e3dio commented 2 years ago

Or use __dirname like { key_file_name: `${__dirname}/privkey.pem` }

x8BitRain commented 2 years ago

Thanks, the above worked!