diff options
Diffstat (limited to 'sleekxmpp/xmlstream/cert.py')
-rw-r--r-- | sleekxmpp/xmlstream/cert.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sleekxmpp/xmlstream/cert.py b/sleekxmpp/xmlstream/cert.py index 339f872d..71146f36 100644 --- a/sleekxmpp/xmlstream/cert.py +++ b/sleekxmpp/xmlstream/cert.py @@ -1,6 +1,10 @@ import logging from datetime import datetime, timedelta +# Make a call to strptime before starting threads to +# prevent thread safety issues. +datetime.strptime('1970-01-01 12:00:00', "%Y-%m-%d %H:%M:%S") + try: from pyasn1.codec.der import decoder, encoder @@ -94,7 +98,7 @@ def extract_names(raw_cert): def extract_dates(raw_cert): if not HAVE_PYASN1: - log.warning("Could not find pyasn1 module. " + \ + log.warning("Could not find pyasn1 and pyasn1_modules. " + \ "SSL certificate expiration COULD NOT BE VERIFIED.") return None, None @@ -130,7 +134,7 @@ def get_ttl(raw_cert): def verify(expected, raw_cert): if not HAVE_PYASN1: - log.warning("Could not find pyasn1 module. " + \ + log.warning("Could not find pyasn1 and pyasn1_modules. " + \ "SSL certificate COULD NOT BE VERIFIED.") return @@ -147,7 +151,10 @@ def verify(expected, raw_cert): raise CertificateError( 'Certificate has expired.') - expected_wild = expected[expected.index('.'):] + if '.' in expected: + expected_wild = expected[expected.index('.'):] + else: + expected_wild = expected expected_srv = '_xmpp-client.%s' % expected for name in cert_names['XMPPAddr']: @@ -160,7 +167,10 @@ def verify(expected, raw_cert): if name == expected: return True if name.startswith('*'): - name_wild = name[name.index('.'):] + if '.' in name: + name_wild = name[name.index('.'):] + else: + name_wild = name if expected_wild == name_wild: return True for name in cert_names['URI']: |