Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print warnings on not being able to load certificates #1132

Open
epsilon-0 opened this issue Nov 27, 2020 · 9 comments
Open

Print warnings on not being able to load certificates #1132

epsilon-0 opened this issue Nov 27, 2020 · 9 comments
Labels

Comments

@epsilon-0
Copy link

I have an SSL app, which ran but all SSL connections failed as the certificates were with incorrect permissions (system admin had messed up).

Knowing that the problem was with the loading of certificates would have been helpful to debug. It took us really long to figure out it was a file issue and not an OpenSSL version issue.
Is there a way to have debug information with the library, so we can catch errors like this?

Thanks,
Aisha

@ghost
Copy link

ghost commented Nov 30, 2020

Didn't the listen function just fail?

@epsilon-0
Copy link
Author

No, it didn't fail. 😮
Trying to read the files was causing an ENOENT error but the listen proceeded and the server was running.

@joshxyzhimself
Copy link

Possibly related, just to add:

I'm on Ubuntu 20.04, uWebSockets.js v18.12.0

@joshxyzhimself
Copy link

joshxyzhimself commented Jan 3, 2021

Update: it looks like it only works on chrome desktop, but not on firefox desktop and chrome android.

I've tried the following but no luck:

let app = null;
let port = null;

const endpoint_domain = 'mydomain.com';
const key_file_name = `/etc/letsencrypt/live/${endpoint_domain}/privkey.pem`;
const cert_file_name = `/etc/letsencrypt/live/${endpoint_domain}/cert.pem`;
const ca_file_name = `/etc/letsencrypt/live/${endpoint_domain}/chain.pem`;

if (fs.existsSync(key_file_name) === true) {
  assert(fs.existsSync(cert_file_name) === true);
  assert(fs.existsSync(ca_file_name) === true);

  app = uws.SSLApp({ key_file_name, cert_file_name, ca_file_name });
  port = 443;
} else {
  app = uws.App({});
  port = 8080;
}

Edit: solved with using the following:

  1. using privkey and fullchain
const key_file_name = `/etc/letsencrypt/live/${endpoint_domain}/privkey.pem`;
const cert_file_name = `/etc/letsencrypt/live/${endpoint_domain}/fullchain.pem`;
  1. using a separate instance for ports 80 and 443. in prod, port 80 instance could simply be a redirect to https://mysite.com/.

Edit: how do I mark my comment as outdated lol.

@ghost
Copy link

ghost commented Jan 19, 2021

Maybe this should be tied up with logging

@ghost ghost mentioned this issue Jan 22, 2021
@ghost ghost added the v19 label Jan 23, 2021
@lolirelia
Copy link

There also seems to be no warnings/errors if uWS is compiled without "WITH_OPENSSL=1" . It compiles and executes without using an ssl context even when the code tells it to.

@joshxyzhimself
Copy link

Should the cert_file_name be changed to fullchain_file_name or cert_ca_file_name?

fullchain.pem = cert.pem + ca.pem, right?

@ghost
Copy link

ghost commented Mar 17, 2021

Renaming things is always fun but breaks backwards compatibility. So even a bad name kept is better than a good name introduced in many cases. You still are allowed to pass only cert, it works both ways.

@uNetworkingAB
Copy link
Contributor

fullchain_file_name is a good name, it can be added as an alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants