uNetworking / uWebSockets

Simple, secure & standards compliant web server for the most demanding of applications
Apache License 2.0
17.29k stars 1.75k forks source link

Segfault in SSLApp / SNI when key/cert files are not readable #1675

Closed myndzi closed 9 months ago

myndzi commented 10 months ago

Hi there. The following code produces a segfault on the latest release:

const uWS = require('uWebSockets.js');

const app = uWS.SSLApp({});
app.addServerName('example.com', {
  key_file_name: '/tmp/nonexistent',
  cert_file_name: '/tmp/nonexistent',
});

Same thing happens if the files exist but aren't readable by the current user.

Ideally, the library would produce a human-meaningful error message (file doesn't exist, or no access, etc.). When creating the repro, I tried just creating an SSLApp with nonexistent files and the error message is just "App construction failed", which could also be improved to give some clue as to why.

uNetworkingAB commented 9 months ago

https://github.com/uNetworking/uSockets/blob/bb86c9c8eee67799af5d016282ee0920945a0fb3/src/crypto/openssl.c#L558

uNetworkingAB commented 9 months ago

fixed in https://github.com/uNetworking/uSockets/commit/a15d9bbdea68fd02dab40d2394200deb1b883aa6