Rev2130, Use SslPatch to load openssl library, Fix Android 6 openssl loading

This commit is contained in:
shortcutme 2017-07-04 01:12:58 +02:00
parent ebbe19131b
commit f30b2b6fc2
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
4 changed files with 43 additions and 49 deletions

View file

@ -4,31 +4,46 @@
import logging
import os
import sys
import ctypes
import ctypes.util
from Config import config
def getLibraryPath():
if sys.platform.startswith("win"):
lib_path = os.path.dirname(os.path.abspath(__file__)) + "/../lib/opensslVerify/libeay32.dll"
elif sys.platform == "cygwin":
lib_path = "/bin/cygcrypto-1.0.0.dll"
elif os.path.isfile("../lib/libcrypto.so"): # ZeroBundle OSX
lib_path = "../lib/libcrypto.so"
elif os.path.isfile("/opt/lib/libcrypto.so.1.0.0"): # For optware and entware
lib_path = "/opt/lib/libcrypto.so.1.0.0"
else:
lib_path = "/usr/local/ssl/lib/libcrypto.so"
if os.path.isfile(lib_path):
return lib_path
if "ANDROID_APP_PATH" in os.environ:
try:
lib_dir = os.environ["ANDROID_APP_PATH"] + "/../../lib"
return [lib for lib in os.listdir(lib_dir) if "crypto" in lib][0]
except Exception, err:
logging.debug("OpenSSL lib not found in: %s (%s)" % (lib_dir, err))
return (ctypes.util.find_library('ssl.so.1.0') or ctypes.util.find_library('ssl') or ctypes.util.find_library('crypto') or ctypes.util.find_library('libcrypto') or 'libeay32')
def openLibrary():
import ctypes
import ctypes.util
try:
if sys.platform.startswith("win"):
dll_path = "src/lib/opensslVerify/libeay32.dll"
elif sys.platform == "cygwin":
dll_path = "/bin/cygcrypto-1.0.0.dll"
else:
dll_path = "/usr/local/ssl/lib/libcrypto.so"
ssl_lib = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL)
assert ssl_lib
except:
dll_path = ctypes.util.find_library('ssl.so.1.0') or ctypes.util.find_library('ssl') or ctypes.util.find_library('crypto') or ctypes.util.find_library('libcrypto')
ssl_lib = ctypes.CDLL(dll_path or 'libeay32', ctypes.RTLD_GLOBAL)
lib_path = getLibraryPath() or "libeay32"
logging.debug("Opening %s..." % lib_path)
ssl_lib = ctypes.CDLL(lib_path, ctypes.RTLD_GLOBAL)
return ssl_lib
def disableSSLCompression():
import ctypes
import ctypes.util
try:
openssl = openLibrary()
openssl.SSL_COMP_get_compression_methods.restype = ctypes.c_void_p