How can I block SSL protocols in PyOpenSSL
in favour of TLS
? I'm using CentOS 7
and have these versions:
pyOpenSSL-0.13.1-3.el7.x86_64
openssl-1.0.1e-34.el7_0.7.x86_64
In my config file (this if for a CherryPy app) I have:
'server.ssl_module': 'pyopenssl',
There are two ways to do it I am aware. One is a configuratio options, and the other is a runtime option.
Configuration Option
The configuration option is used when building OpenSSL. Its great for all applications because it applies your administrative policy and addresses applications which are not mindful to SSL/TLS related issues.
For this option, simply configure OpenSSL with
no-ssl2 no-ssl3
.no-comp
is also often used because compression can leak information.Other OpenSSL options are available, and you might want to visit Compilation and Installation on OpenSSL's wiki.
Runtime Option
In C, you have to (1) use the 2/3 method to get SSL 2/3 and above; and then (2) call
SSL_CTX_set_options
(orSSL_set_options
) and (3) remove the SSL protocols. That leaves the TLS protocols:In Python, you do it with
OpenSSL.SSL.Context.set_options
.This is really good question for CherryPy today. This month we started discussing SSL issues and overall maintainability of CherryPy's wrappers over py2.6+
ssl
and pyOpenSSL in CherryPy user group. I'm planning a topic about SSL issues there, so you can subscribe for the group to get more details later.For now, here's what is possible. I had Debian Wheezy, Python 2.7.3-4+deb7u1, OpenSSL 1.0.1e-2+deb7u16. I've installed CherryPy from the repo (3.6 has broken SSL), and pyOpenSSL 0.14. I tried to override both CherryPy SSL adapters to gain some points in Qualys SSL labs test. It is very helpful and I strongly suggest you to test your deployment with it (whatever is your frontend, CherryPy or not).
As a result,
ssl
-based adapter still has vulnerabilities which I don't see the way to workaround in py2 < 2.7.9 (massive SSL update) and py3 < 3.3. Because CherryPyssl
adapter was written long before these changes, it needs a rewrite to support both old and new ways (mostly SSL Contexts). On the other hand with subclassed pyOpenSSL adapted it's mostly fine, except for:SSL.OP_SINGLE_DH_USE
could have helped but it didn't. May also depend on version of OpenSSL.Here's the code.
Update
Here's the article and discussion where future of CherryPy's SSL support should be decided.