如何使用cherrypy builtin ssl模块禁用SSL3和弱密码(python 3)

gc5*_*gc5 6 python ssl cherrypy python-3.x

我已经使用Python 3配置了Cherrypy 3.8.0以使用SSL/TLS.但是,我想禁用SSL3以避免POODLE.我搜索了文档,但我不确定如何实现它.

我正在使用cherrypy/python内置ssl模块,而不是pyOpenSSL我在Python 3下无法使用的模块.

Mic*_*nas 6

要禁用SSL3,您应该ssl_context自己设置变量,而不是接受默认值.这是使用Python的内置ssl模块(代替内置的cherrypyssl模块)的示例.

import cherrypy
import ssl

ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ctx.options |= ssl.OP_NO_SSLv2 
ctx.options |= ssl.OP_NO_SSLv3

cherrypy.config.update(server_config)
Run Code Online (Sandbox Code Playgroud)

在这种情况下,SSL来自OpenSSL模块.

值得注意的是,从Python 3.2.3开始,该ssl模块默认禁用某些弱密码.

此外,您可以专门设置所需的所有密码

ciphers = {
    'DHE-RSA-AE256-SHA',
    ...
    'RC4-SHA'
}

ctx.set_ciphers(':'.join(ciphers))
Run Code Online (Sandbox Code Playgroud)

如果您使用的CherryPyWSGIServerweb.wsgiserver模块,则可以设置默认密码

CherryPyWSGIServer.ssl_adapter.context.set_cipher_list(':'.join(ciphers))
Run Code Online (Sandbox Code Playgroud)

以下是详细说明上述内容的文档的一部分:http://docs.cherrypy.org/en/latest/pkg/cherrypy.wsgiserver.html#module-cherrypy.wsgiserver.ssl_builtin

最后,您可能需要查看以下内容(询问类似问题):