Skip to content
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

Is it possible to configure pyopenssl to negotiate TLS-1.2-or-worse? #624

Closed
njsmith opened this issue Apr 29, 2017 · 4 comments · Fixed by #861
Closed

Is it possible to configure pyopenssl to negotiate TLS-1.2-or-worse? #624

njsmith opened this issue Apr 29, 2017 · 4 comments · Fixed by #861

Comments

@njsmith
Copy link
Contributor

njsmith commented Apr 29, 2017

Yeah, that's not a typo...

I have a TLS transport implementation. It has tests. One of the things the tests spend a lot of effort on is checking that renegotiation is handled correctly.

In TLS 1.3, renegotiation has been removed from the protocol. For reasons that careful readers may be able to infer from the previous paragraph, I think this is a great idea. However, renegotiation has one last "f you" for me: this is going to break my test suite, because once TLS 1.3 support ships then my renegotiation tests will start negotiating 1.3 and then blow up when I try to do explicit renegotiations. (I'm pretty sure. I guess there's also some chance that they'll seem to work but actually not test anything. Just the kind of thing we like in our security-sensitive code.)

At first I thought I could avoid this by using PROTOCOL_TLS_v1_2, but then my tests fail on py35 + MacOS because the code I'm trying to test uses stdlib ssl, and because Apple hates security and wants me to suffer.

So really what I want is a way to say "negotiate whatever you want, as long as it's 1.2 or worse". Is that possible? I see SSL_CTX_set_max_proto_version in the openssl manual, but in the pyopenssl docs I only see the OP_NO_* constants. I guess I could make those work, but then I have a timebomb where my tests will break when 1.4 is released. Which admittedly is not likely to happen anytime soon, but it makes me itch a bit. Or I guess I could just not test on MacOS b/c if Apple hates security then who am I to argue...?

@tiran
Copy link

tiran commented Apr 29, 2017

SSL_CTX_set_max_proto_version() is OpenSSL 1.1.0+. It's not available in 1.0.2 and earlier. In order to allow TLS 1.0, 1.1 and 1.2, do

  • use PROTOCOL_SSLv23
  • set flags OP_NO_SSLv2 | OP_NO_SSLv3 | getattr(module, 'OP_NO_TLSv1_3', 0)

I'm going to add the flag to Python soon, https://bugs.python.org/issue29136 . @hynek can add the flag to PyOpenSSL as soon it is available in cryptography.

@njsmith
Copy link
Contributor Author

njsmith commented Apr 29, 2017

As mentioned, the OP_NO_* flags are an option, but make me a little nervous because of the lack of future-proofing. Maybe I'm overthinking this... Are the cryptography wheels shipping openssl 1.1 yet? I'm not too worried if my test suite needs a recent version of tls...

though hmm, reading bpo-29136 gives me an idea: I could set an explicit list of allowed ciphers, and that will implicitly prevent TLS1.3+ from being negotiated :-)

@alex
Copy link
Member

alex commented Apr 29, 2017 via email

@tiran
Copy link

tiran commented Apr 29, 2017

@njsmith No, a restricted cipher list won't prevent TLS 1.3. I've done some experiments with OpenSSL master, NSS and mod_nss in the past. Libraries will prefer TLS 1.3 if both sides have TLS 1.3 enabled. Without TLS 1.3 cipher suites, cipher suite negotiation fails and the connection is aborted.

njsmith added a commit to njsmith/trio that referenced this issue May 1, 2017
The problem is we want to require < TLS 1.3, because those are the
versions that have renegotiation, but there isn't a trivial way to say
this in (Py)OpenSSL (or at least, not on any (Py)OpenSSL we currently
have access to). We previously did this by forcing TLS 1.2 only, but
the CI tests are breaking on MacOS, because CPython 3.5 on MacOS uses
such an ancient OpenSSL that it can't speak TLS 1.2 to the test
harness.

Some discussion:
pyca/pyopenssl#624
@alex alex closed this as completed in #861 Aug 2, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants