Raise an explicit BackendError on TLS failures

This change is a port of an existing pull request for ldappool [1]

It simply raises a more appropriate error / stacktrace if unable
to bind.

[1] https://github.com/mozilla-services/ldappool/pull/3

Change-Id: I3a17160a76122a1e4d05112fc86e346dea5dd88b
This commit is contained in:
Lorenzo M. Catucci 2016-05-12 19:14:43 -07:00 committed by Steve Martinelli
parent feed0a08c8
commit 61695772c5
1 changed files with 6 additions and 0 deletions

View File

@ -187,6 +187,12 @@ class ConnectionManager(object):
def _bind(self, conn, bind, passwd):
# let's bind
if self.use_tls:
try:
conn.start_tls_s()
except Exception:
raise BackendError('Could not activate TLS on established '
'connection with %s' % self.uri,
backend=conn)
conn.start_tls_s()
if bind is not None: