summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fieber <florian@florianfieber.de>2012-08-19 16:20:58 +0200
committerLance Stout <lancestout@gmail.com>2012-08-23 00:22:22 -0700
commite510875f649bc08adba3051785ce9140ca43137c (patch)
treeca8e258441b823bef32f1206a4853fe4e964d6f5
parent8a03bd72ae5d07ebee2bcd13e66441a94edd4f1a (diff)
downloadslixmpp-e510875f649bc08adba3051785ce9140ca43137c.tar.gz
slixmpp-e510875f649bc08adba3051785ce9140ca43137c.tar.bz2
slixmpp-e510875f649bc08adba3051785ce9140ca43137c.tar.xz
slixmpp-e510875f649bc08adba3051785ce9140ca43137c.zip
Fix certificate expiration scheduler
timedelta.seconds does not store the total seconds of a time span. Internally, seconds is the next smaller unit to days, hence timedelta.seconds will never exceed (or reach) the number of seconds in a day (60*60*24=86400)
-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 df06d067..246bc205 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -901,9 +901,15 @@ class XMLStream(object):
log.warn('CERT: Certificate has expired.')
restart()
+ try:
+ total_seconds = cert_ttl.total_seconds()
+ except AttributeError:
+ # for Python < 2.7
+ total_seconds = (cert_ttl.microseconds + (cert_ttl.seconds + cert_ttl.days * 24 * 3600) * 10**6) / 10**6
+
log.info('CERT: Time until certificate expiration: %s' % cert_ttl)
self.schedule('Certificate Expiration',
- cert_ttl.seconds,
+ total_seconds,
restart)
def _start_keepalive(self, event):