-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Don't set just 1 curve for ECDHE. #927
Conversation
8d92163
to
820c8fa
Compare
|
Hi @kroeckx - had you intended to submit this ticket for review? The trac ticket does not have a |
|
I think I've done so now. |
|
Can someone please look at this? This fixes a problem preventing people from connecting to certain sites. |
|
@kroeckx could I suggest you add a news fragment as per https://twistedmatrix.com/trac/wiki/ReviewProcess#Newsfiles, which I think will fix the CI failure? |
|
Unfortunately the code in this PR isn't quite right. The situation is complicated because of the interactions of two separate libraries with shifting APIs: OpenSSL
pyOpenSSL
As @kroeckx's contribution demonstrates, the source of this bug is that Twisted always explicitly sets the ECDH curve and key, and thus implements only case 1 when it should support cases 1-3. Twisted currently depends on pyOpenSSL 16.0.0 or later, so it cannot assume case 4. (An additional problem is that Twisted calls private APIs to set the ECDH curve on the I think we'll have to check the version of OpenSSL
|
|
This bug affects Synapse as well: matrix-org/synapse#2350 |
|
My intention was to support OpenSSL 1.0.2+, because OpenSSL 1.0.1 is no longer supported. Since twisted now actually sets the wrong thing, we at least need to change twisted to support OpenSSL 1.1, and we could just do the support for OpenSSL 1.0.2+ regardless of the version of pyOpenSSL. But I guess in the long time if you could require >= 17, you could remove the other code. Looking at the patch in pyOpenSSL, my call is probably wrong and I'll update it. It also only supports OpenSSL 1.0.2+ |
4096615
to
b10d92d
Compare
|
So I've just rebased and pushed a new version. |
|
I've stolen @alex's query from SELECT
STRFTIME_UTC_USEC(timestamp, "%Y-%m") AS yyyymm,
ROUND(100 * SUM(CASE
WHEN SUBSTR(REGEXP_EXTRACT(details.openssl_version, r"^OpenSSL ([^ ]+) "), 0, 5) = "0.9.8" THEN 1
ELSE 0 END) / COUNT(*), 1) AS percent_098,
ROUND(100 * SUM(CASE
WHEN SUBSTR(REGEXP_EXTRACT(details.openssl_version, r"^OpenSSL ([^ ]+) "), 0, 5) = "1.0.0" THEN 1
ELSE 0 END) / COUNT(*), 1) AS percent_100,
ROUND(100 * SUM(CASE
WHEN SUBSTR(REGEXP_EXTRACT(details.openssl_version, r"^OpenSSL ([^ ]+) "), 0, 5) = "1.0.1" THEN 1
ELSE 0 END) / COUNT(*), 1) AS percent_101,
ROUND(100 * SUM(CASE
WHEN SUBSTR(REGEXP_EXTRACT(details.openssl_version, r"^OpenSSL ([^ ]+) "), 0, 5) = "1.0.2" THEN 1
ELSE 0 END) / COUNT(*), 1) AS percent_102,
ROUND(100 * SUM(CASE
WHEN SUBSTR(REGEXP_EXTRACT(details.openssl_version, r"^OpenSSL ([^ ]+) "), 0, 5) = "1.1.0" THEN 1
ELSE 0 END) / COUNT(*), 1) AS percent_110,
COUNT(*) AS download_count
FROM
TABLE_DATE_RANGE( [the-psf:pypi.downloads], DATE_ADD(CURRENT_TIMESTAMP(), -1, "year"), CURRENT_TIMESTAMP() )
WHERE
details.openssl_version IS NOT NULL
AND file.project = 'twisted'
GROUP BY
yyyymm
ORDER BY
yyyymm DESC
LIMIT
100Here's what BigQuery has to say:
It looks like half our users use OpenSSL 1.0.1. That unfortunately argues in favor of supporting it. |
|
It's worth noting that for users who obtained a cryptography wheel, they'll get an OpenSSL 1.1.0; so that's really a pessimistic number. |
495e88b
to
e2eaf50
Compare
|
So I've pushed a version that checks the OpenSSL version. |
|
So do you think this patch is ready, or do you want me to make other changes? |
Codecov Report
@@ Coverage Diff @@
## trunk #927 +/- ##
==========================================
- Coverage 91.9% 91.54% -0.37%
==========================================
Files 840 840
Lines 149182 149188 +6
Branches 13073 13074 +1
==========================================
- Hits 137106 136572 -534
- Misses 9979 10503 +524
- Partials 2097 2113 +16 |
|
See the work from #928 . I think that the changes from here are in conflict with that PR. Thanks! |
|
I would like to get this fixed in Debian stable, which uses pyOpenSSL 16.2. I think the intention of #928 is to rely on a newer version of pyOpenSSL, but then there doesn't seem to be a version of pyOpenSSL yet that does the right thing. So I prefer to use this simple patch for now, which should make it easy for people to backport it. |
|
@kroeckx my call was to get hold of @markrwilliams and agree on a way forward or at least leave your feedback / review on #928 As a reviewer, I have approved #928 ... so if you don't want it merged please leave a comment on that PR with your objection :) There are already a lot of people involved in this PR, so I will hold my review for now :) Regarding the lack of newer pyOpenSSL in distro X. If you want to use pyOpenSSL from distro X my answer is to also use the Twisted version provided by the distro. And if you manage to get a newer version of Twisted in distro X you should also get a newer version of pyOpenSSL This is just my view. In Twisted we already support a lot of platforms / operations system and this is hard. |
Twisted depends on pyOpenSSL 16.0.0, and |
src/twisted/internet/_sslverify.py
Outdated
| self._ecCurve = None | ||
| # Only select a curve for OpenSSL < 1.0.2, in 1.0.2+ we use the | ||
| # automatic mode that supports multiple curves | ||
| if SSL.OPENSSL_VERSION_NUMBER < 0x10002000: |
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.
I was surprised to see that this was green, since Twisted ends up installing cryptography 2.1.3, which should include OpenSSL 1.1.
It turns out we have a Python 3.3 Travis environment with OpenSSL 1.0.1f The cryptography project doesn't ship manylinux1 wheels for Python 3.3, so this job builds cryptography 2.1.3 against OpenSSL 1.0.1 and runs the code in this block.
That's fine for this PR but bad in general because Python 3.3 has reached its end of life and Twisted will probably drop support for it. We'll need builders with OpenSSL 1.0.1 if we're going to support it going forward.
src/twisted/internet/_sslverify.py
Outdated
| try: | ||
| self._ecCurve = _OpenSSLECCurve(_defaultCurveName) | ||
| except NotImplementedError: | ||
| pass; |
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.
The ; should go.
|
I have no idea why GitHub thinks I closed this. |
This fixes track ticket https://tm.tl/9210.
Contributor Checklist:
I would like to point out that I've never written any python code, so please at least check that what I'm doing makes sense, I'm really just guessing what I should do. I for instance have no idea whether
self._lib.set_ecdh_autoexists at all. I did not test this with OpenSSL 1.0.2, but it seems to works with OpenSSL 1.1.0.