Commit 94ba38c0 authored by Ng Pheng Siong's avatar Ng Pheng Siong

Add parameter 'weak_crypto' to Context.__init__; 'weak_crypto' defaults to None,…

Add parameter 'weak_crypto' to Context.__init__; 'weak_crypto' defaults to None, which means no SSLv2 and no weak ciphers.

git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@250 2715db39-9adf-0310-9c64-84f055769b4b
parent e9bfd584
......@@ -32,7 +32,7 @@ class Context:
"""'Context' for SSL connections."""
def __init__(self, protocol='sslv23'):
def __init__(self, protocol='sslv23', weak_crypto=None):
proto = getattr(m2, protocol + '_method')
if proto is None:
raise ValueError, "no such protocol '%s'" % protocol
......@@ -40,6 +40,10 @@ class Context:
self.allow_unknown_ca = 0
map()[self.ctx] = self
m2.ssl_ctx_set_cache_size(self.ctx, 128L)
if weak_crypto is None:
if protocol == 'sslv23':
self.set_options(m2.SSL_OP_ALL | m2.SSL_OP_NO_SSLv2)
self.set_cipher_list('ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH')
def __del__(self):
m2.ssl_ctx_free(self.ctx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment