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

Add SSL CA bundle option #1024

Merged
merged 1 commit into from
Apr 15, 2017
Merged

Add SSL CA bundle option #1024

merged 1 commit into from
Apr 15, 2017

Conversation

metsjeesus
Copy link
Contributor

Letsencrypt serts give me errors on firefox. ERR_CERT_AUTHORITY_INVALID , to fix it, it needs a CA bundle file. Currently, lounge does not accept this, so i made one.

src/server.js Outdated
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath)
}, app);
if (config.https.ca.length && fs.existsSync(caPath)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't seem right.

I'm assuming you mean (config.https.ca.length && !fs.existsSync(caPath))

Also, you'd probably want to do "caPath" rather than "config.https.ca", yeah?

src/server.js Outdated
log.error("Path to SSL ca bundle is invalid. Stopping server...");
process.exit();
}
if (config.https.ca.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be dreadful to restructure this to do:

server = server.createServer({
  key: fs.readFileSync(keyPath),
  cert: fs.readFileSync(certPath),
  ca:  caPath ? fs.readFileSync(caPath) : undefined
}, app);

That should? work exactly the same (test it), but it also removes the duplicate code, and looks much nicer, imo.

@metsjeesus
Copy link
Contributor Author

Changed as requested, can test it on nightime.

@metsjeesus
Copy link
Contributor Author

For my case, its working.

src/server.js Outdated
@@ -53,9 +54,14 @@ module.exports = function() {
log.error("Path to SSL certificate is invalid. Stopping server...");
process.exit();
}
if (config.https.ca.length && !fs.existsSync(caPath)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change config.https.ca.length to caPath.length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Idea is to check if configuration parameter is wrongly set. That means parameter exists and file is missing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caPath is just config.https.ca with normalised "~" is it not? So what's the need to use config.https.ca? That's extra characters. If config.https.ca is "", then caPath will be "".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, its easier to understand what is config.https.ca then Helper.expandHome(config.https.ca). Speciel when same style is applied on config.https.key and config.https.certificate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those would be changed as well (not as part of your pr). You created the variable, so it should be used here. It's confusing not using it because it leads one to wonder why you aren't using it, and the only reason is because that's what we do with the others.

@metsjeesus
Copy link
Contributor Author

Changed, I could change other ssl file paths too, so they use same style.

src/server.js Outdated
@@ -53,9 +54,14 @@ module.exports = function() {
log.error("Path to SSL certificate is invalid. Stopping server...");
process.exit();
}
if (caPath.length && !fs.existsSync(caPath)) {
log.error("Path to SSL ca bundle is invalid. Stopping server...");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CA bundle is not required to run TLS, don't kill the server if there isn't one provided. This whole if isn't even required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point of this is just that if you specify a ca, but it doesn't exist...that's an error.

If you don't specify a ca, then it'll go through fine. But we don't want to pass through nonsense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whoops, yeah, that makes sense.

Copy link
Member

@AlMcKinlay AlMcKinlay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, good addition, thanks for this.

@xPaw
Copy link
Member

xPaw commented Apr 14, 2017

Squash the commits and then 👍

@astorije
Copy link
Member

Also @metsjeesus, mind rebasing with master to fix the conflicts on src/server.js?

@astorije astorije added this to the 2.3.0 milestone Apr 15, 2017
@astorije astorije merged commit 6ae6600 into thelounge:master Apr 15, 2017
@astorije
Copy link
Member

Thanks!

@metsjeesus metsjeesus deleted the ssl_bundle branch April 16, 2017 15:13
@astorije astorije added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Jun 5, 2017
matburnham pushed a commit to matburnham/lounge that referenced this pull request Sep 6, 2017
@astorije
Copy link
Member

Hey @metsjeesus, we have sticker packs for our contributors now!
If you're interested, go fill the form at https://goo.gl/forms/f5usqAEp5DWoeXC92 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants