Nefit Easy stopped working, sleekxmpp error

Hi,

I have been using this component and up till a few days ago it was working flawlessly.

A few days ago it stopped working and I get these errors:

Fri Dec 15 2017 10:03:31 GMT+0100 (West-Europa (standaardtijd))

time data '160530000000Z' does not match format '%Y%m%d%H%M%SZ'
Traceback (most recent call last):
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1492, in _process
    if not self.__read_xml():
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1564, in __read_xml
    self.__spawn_event(xml)
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1632, in __spawn_event
    handler.prerun(stanza_copy)
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/handler/callback.py", line 64, in prerun
    self.run(payload, True)
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/handler/callback.py", line 76, in run
    self._pointer(payload)
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/features/feature_starttls/starttls.py", line 64, in _handle_starttls_proceed
    if self.xmpp.start_tls():
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 889, in start_tls
    cert.verify(self._expected_server_name, self._der_cert)
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-packages/sleekxmpp/xmlstream/cert.py", line 133, in verify
    not_before, not_after = extract_dates(raw_cert)
  File "/home/michel/.homeassistant/deps/lib/python3.5/site-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.5/_strptime.py", line 510, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime
    (data_string, format))
ValueError: time data '160530000000Z' does not match format '%Y%m%d%H%M%SZ'

and:
Log Details (WARNING)
Fri Dec 15 2017 10:03:11 GMT+0100 (West-Europa (standaardtijd))

Nefit api returned invalid data

as well as:

Log Details (WARNING)
Fri Dec 15 2017 10:03:01 GMT+0100 (West-Europa (standaardtijd))

Update of climate.nefit is taking over 10 seconds

Anyone have a clue as to what might be wrong?

The nefit/bosch/junkers xmpp server (used as proxy to communicate with the thermostat) seems to return a ssl/tls certificate with unexpected date string. It seems to miss the century (’%Y’ expects 4 digits for the year) but the printed date string has only ‘16’ has year.
What confuses me is that it is working here fine so that hints to a local issue.

Any idea what I could do to isolate the problem?

I’d start with trying nefit client standalone (in a new virtualenv / on a different computer).

Thx,

I haven’t tried this specific one, but the other one (https://github.com/robertklep/nefit-easy-client) I am using for an old domoticz setup on the same machine still works.

After digging a little into the code, I guess you have the python packages pyasn1 and pyasn1_modules installed. If these packages are not installed, the XMPP client library sleekxmpp doesn’t check the server certificate at all. Unfortunately the code checking the cert is not very good at that:

Just downgrading the module leeds to the next problem:

The only really dirty quickfix I can offer, is that you search for the file .../site-packages/sleekxmpp/xmlstream/cert.py and manually patch it.
If you insert the line:
HAVE_PYASN1 = False
After the try except block at the beginning it should work as before.

Yeah, I know why I didn’t try to get the module into the official Home Assistant code…

Hi,

I looked at the cert.py and it now (originally) says:

try:
    from pyasn1.codec.der import decoder, encoder
    from pyasn1.type.univ import Any, ObjectIdentifier, OctetString
    from pyasn1.type.char import BMPString, IA5String, UTF8String
    from pyasn1.type.useful import GeneralizedTime
    from pyasn1_modules.rfc2459 import (Certificate, DirectoryString,
                                        SubjectAltName, GeneralNames,
                                        GeneralName)
    from pyasn1_modules.rfc2459 import id_ce_subjectAltName as SUBJECT_ALT_NAME
    from pyasn1_modules.rfc2459 import id_at_commonName as COMMON_NAME

    XMPP_ADDR = ObjectIdentifier('1.3.6.1.5.5.7.8.5')
    SRV_NAME = ObjectIdentifier('1.3.6.1.5.5.7.8.7')

    HAVE_PYASN1 = True
except ImportError:
    HAVE_PYASN1 = False

Since it already says HAVE_PYASN1 = False after the except block, I’m unsure what you mean.

Brilliant module, it such a shame it didn’t make it into the official code!

1 Like

Just to set both to false and nefit is back on again :slight_smile:

try:
    from pyasn1.codec.der import decoder, encoder
    from pyasn1.type.univ import Any, ObjectIdentifier, OctetString
    from pyasn1.type.char import BMPString, IA5String, UTF8String
    from pyasn1.type.useful import GeneralizedTime
    from pyasn1_modules.rfc2459 import (Certificate, DirectoryString,
                                        SubjectAltName, GeneralNames,
                                        GeneralName)
    from pyasn1_modules.rfc2459 import id_ce_subjectAltName as SUBJECT_ALT_NAME
    from pyasn1_modules.rfc2459 import id_at_commonName as COMMON_NAME

    XMPP_ADDR = ObjectIdentifier('1.3.6.1.5.5.7.8.5')
    SRV_NAME = ObjectIdentifier('1.3.6.1.5.5.7.8.7')

    HAVE_PYASN1 = False
except ImportError:
    HAVE_PYASN1 = False
1 Like