Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix TypeError with SSL and no keyfile in Python 3.

  • Loading branch information...
commit 512337d87ec77ccc84c125d11b05b61d26b12464 1 parent 6566f3f
@ajdavis ajdavis authored
Showing with 14 additions and 5 deletions.
  1. +14 −5 motor/__init__.py
View
19 motor/__init__.py
@@ -191,11 +191,20 @@ def __init__(
self.use_ssl = use_ssl
self.timeout = None
if self.use_ssl:
- ssl_options = {
- 'certfile': certfile,
- 'keyfile': keyfile,
- 'ca_certs': ca_certs,
- 'cert_reqs': cert_reqs}
+ # In Python 3, Tornado's ssl_options_to_context fails if
+ # any options are None.
+ ssl_options = {}
+ if certfile:
+ ssl_options['certfile'] = certfile
+
+ if keyfile:
+ ssl_options['keyfile'] = keyfile
+
+ if ca_certs:
+ ssl_options['ca_certs'] = ca_certs
+
+ if cert_reqs:
+ ssl_options['cert_reqs'] = cert_reqs
self.stream = iostream.SSLIOStream(
sock, ssl_options=ssl_options, io_loop=io_loop)
Please sign in to comment.
Something went wrong with that request. Please try again.