From 39b5629531d08b69ead4fc18203ca52095d7198e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20J=C3=BCrgens?= Date: Thu, 16 Jan 2020 14:57:01 +0100 Subject: [PATCH] Fix crypto imports on macOS Catalina --- telethon/crypto/libssl.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/telethon/crypto/libssl.py b/telethon/crypto/libssl.py index f1421e57..e8ca90a3 100644 --- a/telethon/crypto/libssl.py +++ b/telethon/crypto/libssl.py @@ -3,6 +3,8 @@ Helper module around the system's libssl library if available for IGE mode. """ import ctypes import ctypes.util +import platform +import sys try: import ctypes.macholib.dyld except ImportError: @@ -15,6 +17,13 @@ __log__ = logging.getLogger(__name__) def _find_ssl_lib(): lib = ctypes.util.find_library('ssl') + # macOS catalina traps the use of unversioned crypto libraries. + # We therefore add the current stable version here + # Credit for fix goes to Sarah Harvey (@worldwise001) + # https://www.shh.sh/2020/01/04/python-abort-trap-6.html + if sys.platform == 'darwin' and platform.mac_ver()[0].startswith('10.15') and lib.endswith('libssl.dylib'): + # libssl.44.dylib is in libressl-2.6 which has a OpenSSL 1.0.1-compatible API + lib = lib.replace('libssl.dylib', 'libssl.44.dylib') if not lib: raise OSError('no library called "ssl" found')