X-Git-Url: https://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ctypescrypto%2F__init__.py;h=c55ae11842d566a6e66b3e772012db690602b9ba;hb=8a2a5ca1f9fc0036d28807d2a9b8a130e560d85b;hp=ba1329ef257477fcda97ad3fbdd490a571e3a2f6;hpb=287e8a5b1d7f5a8129619f733adbfc8b2de3e4c7;p=oss%2Fctypescrypto.git 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()