Repository navigation
Conversation
| return true; | ||
| } | ||
|
|
||
| bool initialize_tls_ctx(SSL_CTX **tls_ctx) { |
There was a problem hiding this comment.
This section needs to be audited.
There was a problem hiding this comment.
I'll have a closer look tomorrow, this'll require some coffee.
| OpenSSL context. The given handshake function is used to perform the handshake | ||
| for the client or server using SSL_connect or SSL_accept respectively. */ | ||
| void linux_secure_tcp_conn_t::establish_conn(SSL_CTX *tls_ctx, int (*handshake)(SSL *) ) THROWS_ONLY(connect_failed_exc_t) { | ||
| conn = SSL_new(tls_ctx); |
There was a problem hiding this comment.
This is not exception safe in that an exception will cause us to leak the allocated memory. We'll probably need to create an RAII wrapper for this.
There was a problem hiding this comment.
I've moved this allocation into the constructors. Since only one raises an exception, I've added a try/catch block which frees the allocated memory before re-throwing the exception.
|
@VeXocide thanks' I'll try to work in your raii wrapper for |
|
Awesome, don't hesitate to ask if you have any other questions regarding C++ or our codebase! |
|
The last commit adds 3 additional options that we discussed: The next few things I was wondering about are:
|
|
Awesome, I'm looking forward to this.
Thanks again for all the work you've done here! |
|
I've got some potentially sad news: I use the following OpenSSL function for ECDHE: int SSL_CTX_set1_curves_list(SSL_CTX *ctx, char *list);
int SSL_set_ecdh_auto(SSL *s, int onoff);But it looks like these are only available in OpenSSL 1.0.2: https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set1_curves.html I don't see any way of configuring ECDHE in earlier versions of I've been building this so far on my Mac with OpenSSL 1.0.2 installed and I ran into an error when trying to build it on an Ubuntu 14.04 system. The latest version available on that distro is What do you guys think I should do? |
|
If it's too hard to make this work with versions older than OpenSSL 1.0.2, we can always bump the required OpenSSL version. Though it wouldn't be ideal, since users won't get security updates from their distributors for OpenSSL if we need to link in our own version. Maybe @VeXocide has an idea? |
|
OpenSSL 1.0.1. does support Fortunately we're not the first to run into this and it turns out there's an undocumented If this isn't an option I'd be comfortable adding |
|
Just after posting I found https://github.com/nodejs/node/blob/master/src/node_crypto.cc#L790 which shows how to select a single curve based on a string. If OpenSSL is at a version below 1.0.2 this is probably the way to go. |
|
On the testing front, this is going to be a bit tricky to do in a proper manner since Python's certificate checking is uneven at best. For building (already at Alternately, it would probably not be too difficult to create |
|
I don't think that this will be relevant for this work, but on MacOS if the non-system version of OpenSSL is used, then you will not have access to the root certificates. So only self-signed certificates would be viable in that case. |
|
@danielmewes @VeXocide Yesterday I added a commit which makes this compatible with older versions of OpenSSL. The tradeoff is that we only get to specify one elliptic curve to use for ECDHE. The default is the P-256 NIST/FIPS curve but we still have an option for specifying a different curve if the system admin knows what they are doing. Let me know what you think. Also, I noticed that there's a developer preview of RethinkDB for Windows which is slated for 2.3. Since this PR is also part of the 2.3 milestone, does that mean I have to make sure this will work on Windows or is there a team of Windows Devs that can port this? Honestly, I haven't investigated how much effort that would be. Oh, one more thing! I published a Docker image which has a build of this branch: https://hub.docker.com/r/jlhawn/rethinkdb-tls/ I tried to make the image as minimal as possible so it's mostly just the |
|
Here's that guide I promised: https://gist.github.com/jlhawn/43f84f86579012470dc9 |
|
You shouldn't worry about the Windows compatibility. |
| } | ||
|
|
||
| // Transfer ownership of the connection to the caller. | ||
| void reclaim() { |
There was a problem hiding this comment.
For consistency with other similar structures in our code and in the standard libraries, I suggest changing this function into the following:
// Transfer ownership of the connection to the caller.
SSL *release() {
rassert(conn != nullptr);
SSL *res = conn;
conn = nullptr;
return res;
}This also fixes two other minor things:
- Use
nullptrinstead ofNULL(this is mostly a stylistic change) - Adds an assertion that the connection hasn't been released before.
rassertsare enabled when compiling withmake DEBUG=1.
I should probably figure out how best to break this into multiple commits. Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
linux_secure_tcp_conn_t has too many messages spamming the logs. Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
--tls-ciphers cipher_list
Allows a system admin to specify a list of TLS ciphers to use. The default
is 'ECDHE+AESGCM'. If, for example, the system (or clients) do not support
newer ECDHE key agreement or GCM an admin could specify:
--tls-ciphers 'DHE+AES'
--tls-ec-curves curve_list
Allows a system admin to specify a list of curves supported by the sytem (and
clients) to use for ECDHE key agreement. To use the curve popularized by
Bitcoin:
--tls-ec-curves secp256k1
--tls-dhparams dhparams_filename
Allows a system admin to specify a file containing Diffie-Hellman parameters
to use with DHE cipher suites. These cipher suites will not be used unless
parameters are specified. As such, this option is required to use DHE cipher
suites. It is highly recommended that a system admin create parameters with
a strong prime of at least 2048 bits in length:
openssl dhparam -out dhparams.pem 2048
and specify using this option:
--tls-dhparams dhparams.pem
Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
While OpenSSL 1.0.2x lets us specify multiple curves to use for ECDHE, those functions are missing from OpenSSL 1.0.1x and earlier! While you can still use ECDHE with these versions of OpenSSL, you may only specify a single curve to use! In order to support these older versions of OpenSSL, the option: --tls-ec-curves curves_list has been replaced with: --tls-ecdh-curve curve_name With the single default curve being 'prime256v1', a.k.a, 'P-256'. System admins may use this option to change the one curve they want to use. Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
I forgot that struct fields are not automatically initialized with zero values. This patch also fixes a minor issue between versions of OpenSSL. Specifically older versions not knowing that ECDHE and EECDH are just different names for the same thing. Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
f726ebc to
533d0ef
Compare
a7f2fab to
fd455ff
Compare
|
Thanks again for updating the PR. |
Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
|
Awesome, this looks good. 🎉 👏 I have to port this to |
Also fixed compilation in DEBUG mode (including unit tests).
Also fixed compilation in DEBUG mode (including unit tests).
Also fixed compilation in DEBUG mode (including unit tests).
This set of commits adds the ability to wrap any of the web, driver, or cluster connections with TLS. The
--helpoutput has been accompanied with the following section:TODO: rebase onto the
nextbranch?fixes #3151
fixes #3158