-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
tls: Use system's openssl.cnf for OpenSSL configuration #5739
Conversation
This allows you to load the standard file system openssl.cnf . Where I connect libgost.so, after which the node -> tls.getCiphers (); and others see the encryption algorithms GOST2001-GOST89-GOST89 Problem: |
|
cc @nodejs/crypto, @ChALkeR |
@fast0490f Could you please fill out the checklist at the top of this issue? Notably, confirm |
@Fishrock123 I added tests and have more information . Please tell me do you need something else ? |
Also, I know that , when adding OPENSSL_config(NULL); solves the problem of connecting the modules to node fips OpenSSL |
What's up with renamed the |
@Trott It tests directory run command 'make -j8' . Sorry, I thought that it is necessary to create a new directory for the test so that you can make sure that my change does not cause errors and conflicts . |
@Trott I corrected my mistake to change the folder |
@Trott @ChALkeR @Fishrock123 I've added a new change that allows you to enable this optional. This reduces the possibility of conflicts and errors for others. I think this is a good solution . |
@@ -3320,6 +3323,8 @@ static void PrintHelp() { | |||
" --force-fips force FIPS crypto (cannot be disabled)\n" | |||
#endif /* NODE_FIPS_MODE */ | |||
#endif /* HAVE_OPENSSL */ | |||
" --openssl-conf-system use the file system kernel configuration " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, openssl-system-conf
? Sounds a bit more logical to me. (Though, I'm not a native speaker myself, so I could be wrong here too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be guarded by HAVE_OPENSSL
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to change the description to something like this:
use system's openssl.cnf for OpenSSL configuration
Some minor nits, otherwise looking quite good! Please let me know if you have any questions, or when it will be ready for next series of review! |
@indutny Hi, I am very glad that you paid attention to my pull request. Thank you for your comments! I made what you adviced.
I have considered the function OPENSSL_config() responsible of it and found out that the function receive the argument but don't use it. Maybe OpenSSL developers reserved this variable for further using, because path is formed by different algorithms to openssl.cnf file. |
#if HAVE_OPENSSL | ||
// used by crypto module | ||
bool openssl_system_conf = false; | ||
#if NODE_FIPS_MODE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do # if NODE_FIPS_MODE
@fast0490f PR looks much better now! Thank you. One more thing, may I ask you to amend https://github.com/nodejs/node/blob/master/doc/node.1 too? Feel free to ask me, if anything will look unfamiliar or hard to you. I'll be glad to help!
It really looks like it is using it on this line. Am I wrong? |
@fast0490f Your git configuration is not reflecting your identity. You might want to check this https://help.github.com/articles/setting-your-username-in-git/ |
Also, the file permissions are messed up. They got changed from 644 to 755. |
@indutny Hi, I made what you adviced =)
I found the following information: |
@thefourtheye Thank you very much for the help, I fixed the comments. |
#if HAVE_OPENSSL | ||
// used by crypto module | ||
bool openssl_system_conf = false; | ||
# if NODE_FIPS_MODE | ||
// used by crypto module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems redundant now, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
@fast0490f I think
I don't get it... it really looks like the path you pass to |
@indutny I really don't know why, but for whatever reason OPENSSL_config() does NOT use the argument as config file path. I haven't done much C/C++ since university, but as far as I can tell it is really so in the source, if you could take a minute to follow: 1, 2, 3, 4 I don't know what the Maybe I should file an issue with OpenSSL (docs?), but the actual behaviour definetely contradicts the description on the site. |
Gosh, sorry about the delay. Looking into it now. |
@burmisov you are right, for some reason it is used as an Meanwhile except one nit (see comments) - this PR LGTM. @nodejs/crypto may I have one more LGTM on this, please? |
Honestly, I think it's a really clunky interface. You pass I suggest we wait until the openssl team releases a fix for the filename/appname thing, cherry-pick that and make |
@bnoordhuis reasonable, let's talk to OpenSSL team first. |
@bnoordhuis seems like it is fixed in master in some sense. They have deprecated ...actually, I just realized that doc is correct:
It is just a really strange wording there, but it doesn't say that |
@indutny @fast0490f I'm late to comment but I'm a bit confused by this pull request. It seems to reintroduce the idea of controlling the OpenSSL's loading of a configuration file via command line argument, which we explored (and chose not to do) in #5181. However, the call to OpenSSL_config(NULL) is already present at https://github.com/geoworks/node/blob/master/src/node_crypto.cc#L5657, and internally OpenSSL will load the default configuration file, or the one from OPENSSL_CONF (if present in the environment) as per https://www.openssl.org/docs/manmaster/crypto/OPENSSL_config.html. Why do we need another call to OpenSSL_Config(NULL) at https://github.com/geoworks/node/blob/master/src/node_crypto.cc#L5650? |
That was introduced with the FIPS support in commit 7c48cb5? Can we remove that? |
Now that there is some attention drawn to this matter, I'd like to point out that this PR (specifically calling OpenSSL_Config(NULL) before other cipher config etc) fixes #5101, and I don't know if there is some other way around that. |
I had a chance to look at this issue further and here are my thoughts, sorry for the wall of text. @bnoordhuis The call to OpenSSL_Config(NULL) already exists in the codebase and works irrespective of any command line options. It was added as part of 7c48cb5 because the OpenSSL configuration has a specific directive for configuring FIPS on or off:
Users experienced with FIPS reported that the config file is the expected way to control the FIPS mode. After the change proposed in this PR the code would look like this:
I'm -1 on this change if we are calling OPENSSL_config twice. Removing the second call will break the convention we already established for FIPS mode, which was that it can be turned on by simply specifying OPENSSL_CONF to point to a file with the correct fips_mode directive. Changing this behaviour may be a semver-major change in my opinion. Now, coming back to the problem reported by @fast0490f and @burmisov: GOST support is provided by a separate engine. This engine is actually bundled with OpenSSL 1.0.x and we have it in the deps/openssl/openssl/engines/ccgost folder. However, by default we seem to compile without it, partly because of these lines (there are also some linking issues that would have to be solved). Therefore, the only way to use GOST is to provide an external library, I'm assuming this is what @fast0490f and @burmisov did using the config file, it looks like this:
This file is already being read without the changes in this PR, but I think the problem is that it's read after SSL_library_init() and friends - meaning that it's probably too late to specify the custom engine and the default one is used instead, without GOST support. tl;dr |
@stefanmb Thanks for the explanations, it is now quite clear to me what is happening. |
thanks guys! :) |
7da4fd4
to
c7066fb
Compare
I'm closing this PR since the solution we agreed on was landed as part of #6374. Thanks to everyone for pointing this out to us! |
Pull Request check-list
Please make sure to review and check all of these items:
make -j8 test
(UNIX) orvcbuild test nosign
(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
make -j8 test
Total errors found: 0