petertodd / python-bitcoinlib

Python3 library providing an easy interface to the Bitcoin data structures and protocol.
Other
1.81k stars 620 forks source link

bitcoin.core.keys links to broken SSL on OSX Catalina #238

Closed sr-gi closed 4 years ago

sr-gi commented 4 years ago

I've been having some issues lately trying to use the library. Just importing some parts of it would make Python crash with a code 134 (interrupted by signal 6: SIGABRT).

After a bit of digging I found out the root of the problem is on SSL linking in bitcoin.core.keys:

_ssl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('ssl') or 'libeay32')

Looks like ctypes.util.find_library('ssl') for OSX Catalina points to /usr/lib/libcrypto.dylib, which is broken, instead of /usr/local/opt/openssl@1.1/lib/libcrypto.dylib.

I've hotfixed it on my machine by hardcoding the path to the proper one and it works fine again.

Similar issues: https://github.com/Homebrew/homebrew-core/issues/44996

Not sure if other users of the library with the same OS version can reproduce, I thought I'd be worth leaving a note just in case.

dhimmel commented 4 years ago

I'm getting a similar issue when running Python 3.8 on GitHub Actions Windows. The issue does not occur for Python 3.6 or 3.7 on Windows or 3.8 on Windows on AppVeyor. It does not occur for any linux or macOS builds.

Here's the stack trace from this build log:

  File "c:\hostedtoolcache\windows\python\3.8.3\x64\lib\site-packages\bitcoin\core\key.py", line 33, in <module>
    _ssl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('ssl') or 'libeay32')
  File "c:\hostedtoolcache\windows\python\3.8.3\x64\lib\ctypes\__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "c:\hostedtoolcache\windows\python\3.8.3\x64\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libeay32' (or one of its dependencies). Try using the full path with constructor syntax.

So the line where the error is raised is:

https://github.com/petertodd/python-bitcoinlib/blob/2326b2106515b9101cdfcd046e46e6ad04275f67/bitcoin/core/key.py#L34