nbxmpp crashes when ca-certificates.crt contains non-ASCII characters
On Arch, the file /etc/ssl/certs/ca-certificates.crt contains comments indicating which authority belongs to which certificate. Some of those comments contain non-ASCII characters like á:
[me@imaginatron ~]$ ./gremlins /etc/ssl/certs/ca-certificates.crt
# NetLock Arany (Class Gold) Főtanúsítvány
# TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5
This makes nbxmpp 0.6.4-1 crash on line 345 of tls_nb.py (f.readlines()).
The problem is easily solved by passing encoding='utf-8' to open(). However, this breaks the library on Python 2. One could choose to use the built-in backport of Python 3's open(), io.open, on Python 2. I was unable to create a pull request so hereby my proposed solution:
Old:
f = open(cert_path)
New:
import io
if sys.version_info[0] > 2:
f = open(cert_path, encoding='utf-8')
else:
f = io.open(cert_path, encoding='utf-8')