summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorThom Nichols <tmnichols@gmail.com>2010-07-07 11:33:12 -0400
committerThom Nichols <tmnichols@gmail.com>2010-07-07 11:33:12 -0400
commitf3cf5f6080b484634e31edaa129c7922ebb62fb6 (patch)
treeef4fa28d45bc5bb3f36f4ab765b3c0ca6df9b630 /sleekxmpp
parent85d8b9270f176e5c0a43b5219e84f75690a016e6 (diff)
downloadslixmpp-f3cf5f6080b484634e31edaa129c7922ebb62fb6.tar.gz
slixmpp-f3cf5f6080b484634e31edaa129c7922ebb62fb6.tar.bz2
slixmpp-f3cf5f6080b484634e31edaa129c7922ebb62fb6.tar.xz
slixmpp-f3cf5f6080b484634e31edaa129c7922ebb62fb6.zip
added SSL certificate verification to startTLS method
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index f968fdb6..887edeff 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -171,12 +171,18 @@ class XMLStream(object):
def startTLS(self):
"Handshakes for TLS"
+ # TODO since this is not part of the 'connectTCP' method, it does not quiesce if
+ # The TLS negotiation throws an SSLError. It really should. Worse yet, some
+ # errors might be considered fatal (like certificate verification failure) in which
+ # case, should we even attempt to re-connect at all?
if self.ssl_support:
logging.info("Negotiating TLS")
# self.realsocket = self.socket # NOT USED
+ cert_policy = ssl.CERT_NONE if self.ca_certs is None else ssl.CERT_REQUIRED
self.socket = ssl.wrap_socket(self.socket,
ssl_version=ssl.PROTOCOL_TLSv1,
- do_handshake_on_connect=False,
+ do_handshake_on_connect=False,
+ cert_reqs=cert_policy,
ca_certs=self.ca_certs)
self.socket.do_handshake()
if sys.version_info < (3,0):