From 336fbbd82a09469a7ac7d0eb850daa6a55f42669 Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Mon, 29 Jun 2015 13:17:55 +0300 Subject: [PATCH] Use find_library to search for openssl libs --- ctypescrypto/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ctypescrypto/__init__.py b/ctypescrypto/__init__.py index ba1329e..c55ae11 100644 --- a/ctypescrypto/__init__.py +++ b/ctypescrypto/__init__.py @@ -5,6 +5,8 @@ from ctypes import CDLL, c_char_p +from ctypes.util import find_library +import sys def config(filename=None): """ @@ -15,6 +17,14 @@ def config(filename=None): __all__ = ['config'] -libcrypto = CDLL("libcrypto.so.1.0.0") +if sys.platform.startswith('win'): + __libname__ = find_library('libeay32') +else: + __libname__ = find_library('crypto') + +if __libname__ is None: + raise OSError("Cannot find OpenSSL crypto library") + +libcrypto = CDLL(__libname__) libcrypto.OPENSSL_config.argtypes = (c_char_p, ) libcrypto.OPENSSL_add_all_algorithms_conf() -- 2.39.2