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

set tls.sessionIdContext property #1740

Merged
merged 1 commit into from
Dec 21, 2016
Merged

set tls.sessionIdContext property #1740

merged 1 commit into from
Dec 21, 2016

Conversation

msimerson
Copy link
Member

@msimerson msimerson commented Dec 12, 2016

Fixes #1739

Changes proposed in this pull request:

  • create a top level scoped secureContext (maybe store it in Redis eventually)
  • consolidate 2x secureContext creations into _getSecureContext()
  • set the context's sessionIdContext (this is the FIX)
  • remove options.secureProtocol default 'SSLv23_method' (that's the node.js default since iojs)
  • remove secureOptions | constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3
    • SSL v2 and v3 were removed from node.js in since io.js
  • remove crypto.createCredentials (deprecated)

Checklist:

  • docs updated
  • tests updated

@codecov-io
Copy link

codecov-io commented Dec 12, 2016

Current coverage is 34.47% (diff: 12.50%)

Merging #1740 into master will increase coverage by 0.01%

@@             master      #1740   diff @@
==========================================
  Files            23         23          
  Lines          5919       5917     -2   
  Methods         761        762     +1   
  Messages          0          0          
  Branches       1503       1500     -3   
==========================================
  Hits           2040       2040          
+ Misses         3879       3877     -2   
  Partials          0          0          

Powered by Codecov. Last update febe3a7...e407e2f

@smfreegard
Copy link
Collaborator

Am I right in thinking that this will not fix #1739 if running with nodes=cpus because if the reconnection happens to a different child (which is likely), then the secureContext will be different?

@msimerson
Copy link
Member Author

msimerson commented Dec 13, 2016

Am I right in thinking that this will not fix #1739 if running with nodes=cpus because if the reconnection happens to a different child (which is likely), then the secureContext will be different?

Close, but not quite. Ya see, the root of the problem is session id context uninitialized, which this PR fixes by setting the id property. Seriously. You have to provide an ID it to initialize it. The OpenSSL docs and the error message both say so. Update: it appears node does initialize the ID with a SHA1 hash.

You are very right to be thinking that the secureContext would best be shared among processes, but if not, or if a client presents a ticket that's not found in the secureContext, that's no big deal as the server will check the context and if missing, create a new ticket. It works almost exactly the same way if you set the sessionTimeout to something really low like 1 second. The TLS ticket ends up being expired after every connection.

@msimerson
Copy link
Member Author

msimerson commented Dec 13, 2016

One of the best explanations is on the OpenSSL users list:

@msimerson msimerson changed the title set tls.sessionIdContext propertly set tls.sessionIdContext property Dec 13, 2016
@msimerson
Copy link
Member Author

Late at night, after all them Thunderbird users are gone to sleep, I snuck in and changed to nodes=4 (having 16 children is just kinda silly) and tested again, just to make sure. I sent a half dozen messages through unhindered. Previously (w/o patch) I could send the first and subsequent attempts (until restarting Thunderbird) would fail.

@msimerson msimerson merged commit 2f9dbb6 into haraka:master Dec 21, 2016
@msimerson msimerson deleted the tls-thunderbird-fix branch December 21, 2016 19:47
gramakri added a commit to cloudron-io/Haraka that referenced this pull request Jan 17, 2017
gramakri added a commit to cloudron-io/Haraka that referenced this pull request Jan 18, 2017
This reverts commit 2f9dbb6.

This is causing some issues:

With the latest haraka we get errors like "Error: 140025275811648:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:../deps/openssl/openssl/ssl/s23_clnt.c:769:" when using old code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants