Skip to content

Commit f44d070

Browse files
committed
core: raise clear error when OpenSSL library is not found
On Windows, ctypes.util.find_library() can return None for all candidate library names. Passing None to LoadLibrary() raises a confusing TypeError. Check for None first and raise an EnvironmentError with an actionable message instead. Fixes #316
1 parent 91e334d commit f44d070

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

bitcoin/core/key.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@
2323
import bitcoin.signature
2424

2525
import bitcoin.core.script
26-
27-
_ssl = ctypes.cdll.LoadLibrary(
28-
ctypes.util.find_library('ssl.35') or ctypes.util.find_library('ssl') or ctypes.util.find_library('libeay32')
29-
or ctypes.util.find_library('libcrypto')
26+
_ssl_library = (
27+
ctypes.util.find_library('ssl.35') or ctypes.util.find_library('ssl')
28+
or ctypes.util.find_library('libeay32') or ctypes.util.find_library('libcrypto')
3029
)
30+
if _ssl_library is None:
31+
raise EnvironmentError(
32+
"OpenSSL library not found. "
33+
"Install OpenSSL and ensure it is on your PATH or system library path."
34+
)
35+
_ssl = ctypes.cdll.LoadLibrary(_ssl_library)
3136

3237
_libsecp256k1_path = ctypes.util.find_library('secp256k1')
3338
_libsecp256k1_enable_signing = False

0 commit comments

Comments
 (0)