NickWaterton / Roomba980-Python

Python program and library to control iRobot Roomba 980 Vacuum Cleaner
MIT License
377 stars 106 forks source link

CentOS: wrong default certificate file, unclear error message #36

Open ZvikaZ opened 6 years ago

ZvikaZ commented 6 years ago

Hi.

I have a CentOS 7 system. When running roomba it fails with:

    [I 2018-06-12 21:00:26,612] Seting TLS
    [E 2018-06-12 21:00:26,614] Error: [Errno 2] No such file or directory 
    Traceback (most recent call last):
      File "/home/zvika/miniconda2/envs/roomba/bin/roomba", line 11, in <module>
        sys.exit(main())
      File "/home/zvika/miniconda2/envs/roomba/lib/python2.7/site-packages/roomba/__main__.py", line 572, in main
        myroomba.connect()
      File "/home/zvika/miniconda2/envs/roomba/lib/python2.7/site-packages/roomba/roomba.py", line 286, in connect
        if not self._connect():
      File "/home/zvika/miniconda2/envs/roomba/lib/python2.7/site-packages/roomba/roomba.py", line 316, in _connect
        if exc_type == socket.error or exc_type == ConnectionRefusedError:
    NameError: global name 'ConnectionRefusedError' is not defined

Which is not a very clear error message... I recommend giving a better error message here, that will explain the real problem.

After debugging it, I found that the problem was due to self.cert_name having a default value of "/etc/ssl/certs/ca-certificates.crt" which is probably good for Debian/Ubuntu distros, but in CentOS (and maybe other distros) that file doesn't exist.

I wasn't sure what's the correct value, but simple find gave me the files:

/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
/etc/pki/ca-trust/source/ca-bundle.legacy.crt

The first one sounded better, so I run the command:

roomba --cert /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt

Which indeed worked well.

Therefore, I recommend changing :

    if not cert_name:
        self.cert_name = "/etc/ssl/certs/ca-certificates.crt"
    else:
        self.cert_name = cert_name

To code that will check if that path exists, and if not, will check if the path I supplied exists, and if not - fail there with an error message recommending using --cert flag, and request to open an issue describing the new path, for the benefit of future users of that distro.

Thanks!