fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

ValueError: day is out of range for month #478

Open Elinvention opened 6 years ago

Elinvention commented 6 years ago
DEBUG:sleekxmpp.xmlstream.xmlstream:Event triggered: ssl_cert
ERROR:sleekxmpp.basexmpp:day is out of range for month
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1492, in _process
    if not self.__read_xml():
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1564, in __read_xml
    self.__spawn_event(xml)
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1632, in __spawn_event
    handler.prerun(stanza_copy)
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/handler/callback.py", line 64, in prerun
    self.run(payload, True)
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/handler/callback.py", line 76, in run
    self._pointer(payload)
  File "/usr/lib/python3/dist-packages/sleekxmpp/features/feature_starttls/starttls.py", line 64, in _handle_starttls_proceed
    if self.xmpp.start_tls():
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 889, in start_tls
    cert.verify(self._expected_server_name, self._der_cert)
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/cert.py", line 133, in verify
    not_before, not_after = extract_dates(raw_cert)
  File "/usr/lib/python3/dist-packages/sleekxmpp/xmlstream/cert.py", line 111, in extract_dates
    not_before = datetime.strptime(not_before, '%Y%m%d%H%M%SZ')
  File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/lib/python3.6/_strptime.py", line 528, in _strptime
    datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month
DEBUG:sleekxmpp.xmlstream.xmlstream:reconnecting...

I can't connect anymore... Version 1.3.3-1 from Debian.

ThomasChiroux commented 6 years ago

Had the same today on one server (in a pool of dozen of other servers, all using sleek 1.3.3, still dont know why this server is different). The reason is the not_before year date from here: https://github.com/fritzy/SleekXMPP/blob/7075a3b7fa857fc8f9db60da9d01fa1a11806659/sleekxmpp/xmlstream/cert.py#L109 was in two digit instead of 4, so strptime with %Y is not working.

Writed a work around in cert.py like this one:

try:
    not_before = datetime.strptime(not_before, '%Y%m%d%H%M%SZ')
except ValueError:
    not_before = datetime.strptime(not_before, '%y%m%d%H%M%SZ')

same for not_after

jowrjowr commented 6 years ago

This is still an issue in 1.3.3

OverloadUT commented 5 years ago

Hi there @fritzy - I'm a contributor to https://github.com/homeassistant/homeassistant

I experience this issue, and it has also come up from many users of Home Assistant, which uses this library by way of https://github.com/wpietri/sucks

Any chance of a new release going out that fixes this issue? We could alternatively pin our dependency to 1.3.2, but I'd rather not do that if a release is forthcoming.

tobiasBora commented 5 years ago

Hello, I confirm this bug with the jwchat.org webservers. Any news?

nicandris commented 5 years ago

I confirm it also on a pi

Neustradamus commented 5 years ago

It is now solved in the develop branche no? The 1.3.2 was good and the 1.3.3 was broken.

meyerdenney commented 5 years ago

FWIW worth I'm still having this issue on Hassio. The sucks library (https://github.com/wpietri/sucks) relies on this dependency which throws a day out of range error, thus breaking everyone who uses the sucks library in Hassio (which runs on a docker container on a raspberry pi).

So even though this problem might seem fixed for those on desktop computers, it still exists for other environments.

meyerdenney commented 5 years ago

Hi there @fritzy - I'm a contributor to https://github.com/homeassistant/homeassistant

I experience this issue, and it has also come up from many users of Home Assistant, which uses this library by way of https://github.com/wpietri/sucks

Any chance of a new release going out that fixes this issue? We could alternatively pin our dependency to 1.3.2, but I'd rather not do that if a release is forthcoming.

@OverloadUT - doesn't hassio use slixmpp and sucks uses sleekxmpp. So wouldn't we have to revert sucks (https://github.com/wpietri/sucks) to use an older version of sleekxmpp and then re-pull sucks into into the hassio? Would that solve the issue? If so, I could always fork sucks if @wpietri doesn't want to revert sleekxmpp

Neustradamus commented 5 years ago

@Elinvention @ThomasChiroux @jowrjowr @OverloadUT @tobiasBora @nicandris @meyerdenney can you publish logs with actual branche?