-
Notifications
You must be signed in to change notification settings - Fork 420
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
Regression: M2Crypto.m2.rand_bytes() hangs on Apache+mod_wsgi with pyOpenSSL 16.1.10 #520
Comments
Does this problem go away if you do:
right after importing pyopenssl? |
I don't import pyopenssl directly, I use it through M2Crypto. Does it make
sense to do this import and call after importing M2Crypto? Or should I do
it before?
|
I'm afraid I'm confused. m2crypto is a completely separate project that just happens to also use OpenSSL. Why would M2Crypto import pyOpenSSL? |
The best theory I can come up with is that my code has an indirect
dependency on pyOpenSSL (via some other library we happen to use), and
there is some bad interaction between M2Crypto's and pyOpenSSL's use of
openssl from within the python runtime embedded in Apache :-(
Debugging this is going to be a bit of a nightmare I'm afraid :-/
|
Yeah that's a strange setup. I suspect doing |
Has this been fixed by the 16.2.0 release? |
Yes, sorry should have closed this one :) |
Any pointers to how this was fixed?
|
There's some discussion on #542 and this is the PR that fixes it: #552 There's shared global state in the OpenSSL backend related to the way we do the random callback for cryptography. This was previously not activated for pyOpenSSL but as an import side effect it started occurring in 16.1. 16.2 moves that import to be scoped specifically to the methods that require it, so it doesn't actually fix the problem but it restores functionality to all existing code while we fix it more permanently. |
Hi, this is M2Crypto maintainer here. First of all, why in the world this bug was filed here, where I haven't learn about it and not in https://gitlab.com/m2crypto/m2crypto/issues , if it is a M2Crypto issue? However, if the bug was filed there, I would most likely close it as an invalid issue. Let me explain. In my opinion, it is absolutely unnecessary for either M2Crypto or python-cryptography to provide ANY random numbers. We do it only because of providing legacy API (one of the topmost goals of M2Crypto project is to support its legacy users, so stability of API is our top goal) and perhaps for those really few who can require some weird hardware entropy generator (I don't even know, whether M2Crypto would be able to support it, OpenSSL does). For all other users, which is 99% of all projects I suppose, Also, why in the world do you feel the need to combine M2Crypto with pyOpenSSL, when the former‘s capabilities are superset of the latter's ones? Linking your program to OpenSSL twice (which is what you do) is effort carrying too many risks of something going wrong, that I would certainly declare it as unsupported and thus close the bug. |
No, the |
Since upgrading:
my web app reliably hangs, in a simple
M2Crypto.m2.rand_bytes(16)
call.At the same time entropy_avail hovers around 800, and calling the function from a standalone python interperter works just fine. Apparently the issue is only when running inside Apache.
Downgrading cryptography alone (to 1.4) does not help. But downgrading pyOpenSSL (to 16.0.0) as well, makes it work again. I did not try downgrading pyOpenSSL alone.
I suspect this is something along the lines of pyca/cryptography#2299, but I don't pretend to understand the details.
Example stack trace of a hanging request thread:
The text was updated successfully, but these errors were encountered: