diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-05-13 15:01:00 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-05-13 15:01:00 -0700 |
commit | 61030206f101f385b1b4e04569c57b0f81fda754 (patch) | |
tree | 0d60a4bed5bd69387278ea4c53452ab02fa7aadf /redis/connection.py | |
parent | 17ff3774a74a251f17ffb1235b8d38a17fa1b13f (diff) | |
download | redis-py-61030206f101f385b1b4e04569c57b0f81fda754.tar.gz |
allow cert_reqs to be a string and convert it to the appropriate SSL constant.
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-x | redis/connection.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/redis/connection.py b/redis/connection.py index 5607508..c209750 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -570,6 +570,16 @@ class SSLConnection(Connection): self.certfile = certfile if cert_reqs is None: cert_reqs = ssl.CERT_NONE + elif isinstance(cert_reqs, basestring): + CERT_REQS = { + 'none': ssl.CERT_NONE, + 'optional': ssl.CERT_OPTIONAL, + 'required': ssl.CERT_REQUIRED + } + if cert_reqs not in CERT_REQS: + raise RedisError( + "Invalid SSL Certificate Required Flag: %s" % cert_reqs) + cert_reqs = CERT_REQS[cert_reqs] self.cert_reqs = cert_reqs self.ca_certs = ca_certs |