-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
OPENSSL_init_ssl fails in RUN_ONCE and ossl_init_config #7350
Comments
|
we call e.g. int r1 = OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL); for our library to init. |
|
What platform are you running on? |
|
(As a workaround you should be able to just remove both the init calls from your code; 1.1.1 will auto-initialize itself. But that does not keep us from wanting to track down what's going on here.) |
|
We use it on Mac, Windows and Linux. But I saw the problem both on Mac and Windows as we didn't test for Linux this time. I can check in the next days for some details. |
|
The problem is precisely that ret = RUN_ONCE(&config, ossl_init_config); returns 0, which than returns a failure from OPENSSL_init_crypto. Can you guys verify that OPENSSL_init_crypto works, if you call it several times with various parameters like OPENSSL_INIT_LOAD_CONFIG or OPENSSL_INIT_NO_LOAD_CONFIG? |
|
We just fell across the same issue, when calling |
|
The problem is that ossl_init_config and ossl_init_no_config share the RUN_ONCE control argument. This means that if ossl_init_no_config was call once, then ossl_init_config will never be called. The return value for RUN_ONCE is a static variable derived from the function name and initialized with '0'. In the failing case, this value is never changed, because the function is never called. Several other option pairs have the same problem. |
This will now load OpenSSL configuration from openssl.cnf default section 'openssl_conf'. This might be useful, anyway, but the main reason we have to change this is to stay consistent with upcoming support for OpenSSL 1.1.1. We also link again libcurl and libcurl uses OPENSSL_init_ssl() which itself calls OPENSSL_init_crypto() with OPENSSL_INIT_LOAD_CONFIG. Now, due to a bug/feature in OpenSSL, it is no more possible to initialize OpenSSL with both 'load config' and 'no config' (refer openssl/openssl#7350 for details and discussion). This forces us to initialize OpenSSL with 'load config', too when we want to support OpenSSL 1.1.1. This is a preparation that changes the old code to gain the same behavior that future OpenSSL-1.1.1 supporting code will have as we do not want to behave differently with different OpenSSL versions. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
This will now load OpenSSL configuration from openssl.cnf default section 'openssl_conf'. This might be useful, anyway, but the main reason we have to change this is to stay consistent with upcoming support for OpenSSL 1.1.1. We also link again libcurl and libcurl uses OPENSSL_init_ssl() which itself calls OPENSSL_init_crypto() with OPENSSL_INIT_LOAD_CONFIG. Now, due to a bug/feature in OpenSSL, it is no longer possible to initialize OpenSSL with both 'load config' and 'no config' (refer openssl/openssl#7350 for details and discussion). This forces us to initialize OpenSSL with 'load config', too, when we want to support OpenSSL 1.1.1. This is a preparation that changes the old code to gain the same behavior that future OpenSSL-1.1.1-supporting code will have as we do not want to behave differently with different OpenSSL versions. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
|
I ran in into this issue too. |
|
I am running into this issue. Because of this in Any attempt to use OPENSSL_INIT_NO_LOAD_CONFIG, OPENSSL_INIT_NO_ADD_ALL_CIPHERS or OPENSSL_INIT_NO_ADD_ALL_DIGESTS before creating an SSL_CTX with |
|
This should be fixed in git (commit f725fe5 for the 1.1.1 branch). Please try out the latest version in OpenSSL_1_1_1-stable and see if that solves the problem. |
|
Was this fixed by PR #7983 ? |
|
@mattcaswell just found that... but it's not in a tagged release, yet. |
Yes, one of the commits in that PR fixed a RUN_ONCE bug that causes this issue.
Correct this is git only so far. The fix will be in 1.1.1b |
Yeah, we deal with the tagged releases, so I'm not spending all my time rebasing our changes. ;) Any idea when 1.1.1b might come out? (It's been, what, almost 3 months since 1.1.1a?) |
|
We tend to do a release every 3-4 months (unless a security issue causes us to do one earlier) ....so "soon". |
|
Thought so... Thanks! |
More info: - openssl/openssl#7350 - openssl/openssl@f725fe5 Without this patch we will get following error: ``` SSL: couldn't create a context: error:00000000:lib(0):func(0):reason(0) ``` during trying to connect HTTPS.
|
Given that 1.1.1b is out, should this issue be closed? |
|
Well, I think for now you can close this. |
This will now load OpenSSL configuration from openssl.cnf default section 'openssl_conf'. This might be useful, anyway, but the main reason we have to change this is to stay consistent with upcoming support for OpenSSL 1.1.1. We also link again libcurl and libcurl uses OPENSSL_init_ssl() which itself calls OPENSSL_init_crypto() with OPENSSL_INIT_LOAD_CONFIG. Now, due to a bug/feature in OpenSSL, it is no longer possible to initialize OpenSSL with both 'load config' and 'no config' (refer openssl/openssl#7350 for details and discussion). This forces us to initialize OpenSSL with 'load config', too, when we want to support OpenSSL 1.1.1. This is a preparation that changes the old code to gain the same behavior that future OpenSSL-1.1.1-supporting code will have as we do not want to behave differently with different OpenSSL versions. Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
With this change, the NGX_OPENSSL_NO_CONFIG macro is defined when nginx is asked to build OpenSSL itself. And with this macro automatic loading of OpenSSL configuration (from the build directory) is prevented unless the OPENSSL_CONF environment variable is explicitly set. Note that not loading configuration is broken in OpenSSL 1.1.1 and 1.1.1a (fixed in OpenSSL 1.1.1b, see openssl/openssl#7350). If nginx is used to compile these OpenSSL versions, configuring nginx with NGX_OPENSSL_NO_CONFIG explicitly set to 0 might be used as a workaround.
With this change, the NGX_OPENSSL_NO_CONFIG macro is defined when nginx is asked to build OpenSSL itself. And with this macro automatic loading of OpenSSL configuration (from the build directory) is prevented unless the OPENSSL_CONF environment variable is explicitly set. Note that not loading configuration is broken in OpenSSL 1.1.1 and 1.1.1a (fixed in OpenSSL 1.1.1b, see openssl/openssl#7350). If nginx is used to compile these OpenSSL versions, configuring nginx with NGX_OPENSSL_NO_CONFIG explicitly set to 0 might be used as a workaround. --HG-- branch : nginx
With this change, the NGX_OPENSSL_NO_CONFIG macro is defined when nginx is asked to build OpenSSL itself. And with this macro automatic loading of OpenSSL configuration (from the build directory) is prevented unless the OPENSSL_CONF environment variable is explicitly set. Note that not loading configuration is broken in OpenSSL 1.1.1 and 1.1.1a (fixed in OpenSSL 1.1.1b, see openssl/openssl#7350). If nginx is used to compile these OpenSSL versions, configuring nginx with NGX_OPENSSL_NO_CONFIG explicitly set to 0 might be used as a workaround.
After upgrade to openssl 1.1.1 we got an issue that all the SSL stuff failed to work.
OPENSSL_init_ssl returned failure due to failure in OPENSSL_init_crypto before.
OPENSSL_init_crypto calls this block:
and that needs to be commented out of us to make it work again.
It looks like that with multiple invocations of OPENSSL_init_crypto in our code and used libraries, the second invocation fails and returns the error here. Not sure why, but now everything works again as it did with older OpenSSL version so far.
The text was updated successfully, but these errors were encountered: