Skip to content

Commit e7a0034

Browse files
committed
Added one-time warning
1 parent 92e47d4 commit e7a0034

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

neo4j/v1/session.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ def driver(url, **config):
8484
return Driver(url, **config)
8585

8686

87+
_warned_about_insecure_default = False
88+
89+
90+
def _warn_about_insecure_default():
91+
global _warned_about_insecure_default
92+
if not SSL_AVAILABLE and not _warned_about_insecure_default:
93+
from warnings import warn
94+
warn("Bolt over TLS is only available in Python 2.7.9+ and Python 3.3+ "
95+
"so communications are not secure")
96+
_warned_about_insecure_default = True
97+
98+
8799
class Driver(object):
88100
""" Accessor for a specific graph database resource.
89101
"""
@@ -99,7 +111,11 @@ def __init__(self, url, **config):
99111
self.config = config
100112
self.max_pool_size = config.get("max_pool_size", DEFAULT_MAX_POOL_SIZE)
101113
self.session_pool = deque()
102-
self.encrypted = encrypted = config.get("encrypted", ENCRYPTED_DEFAULT)
114+
try:
115+
self.encrypted = encrypted = config["encrypted"]
116+
except KeyError:
117+
_warn_about_insecure_default()
118+
self.encrypted = encrypted = ENCRYPTED_DEFAULT
103119
self.trust = trust = config.get("trust", TRUST_DEFAULT)
104120
if encrypted:
105121
if not SSL_AVAILABLE:

0 commit comments

Comments
 (0)