From a1e8cee482709318a2fc4b9486b4ccc59768532c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 13 Apr 2018 00:30:47 +0200 Subject: Fix parsing utf8 cert files Fixes #51 --- nbxmpp/tls_nb.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nbxmpp/tls_nb.py b/nbxmpp/tls_nb.py index 32b79ef..6405ed6 100644 --- a/nbxmpp/tls_nb.py +++ b/nbxmpp/tls_nb.py @@ -24,6 +24,7 @@ from .plugin import PlugIn import sys import os import time +import io import traceback @@ -337,7 +338,10 @@ class NonBlockingTLS(PlugIn): if not os.path.isfile(cert_path): return try: - f = open(cert_path) + if sys.version_info[0] > 2: + f = open(cert_path, encoding='utf-8') + else: + f = io.open(cert_path, encoding='utf-8') except IOError as e: log.warning('Unable to open certificate file %s: %s' % \ (cert_path, str(e))) -- cgit v1.2.3