xyuanmu / XX-Mini

:ghost: XX-Net 精简版
443 stars 125 forks source link

linux下运行XX-Mini产生openssl和cryptography报错的解决办法 #10

Open mebest100 opened 8 years ago

mebest100 commented 8 years ago

linux下运行XX-Mini会产生openssl和cryptography报错(平台:Ubuntu15.10 x64, python2.7.10,同样的XXnet没有这样的报错):

python proxy.py

Traceback (most recent call last): File "proxy.py", line 74, in from cert_util import CertUtil File "/home/yuan/XX-mini-linux/lib.egg/lib/cert_util.py", line 23, in File "/usr/lib/python2.7/dist-packages/OpenSSL/init.py", line 8, in from OpenSSL import rand, crypto, SSL File "/usr/lib/python2.7/dist-packages/OpenSSL/rand.py", line 11, in from OpenSSL._util import ( File "/usr/lib/python2.7/dist-packages/OpenSSL/_util.py", line 6, in from cryptography.hazmat.bindings.openssl.binding import Binding File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/openssl/binding.py", line 11, in from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: /usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/_openssl.x86_64-linux-gnu.so: symbol EC_GFp_nistp521_method, version OPENSSL_1.0.1 not defined in file libcrypto.so.1.0.0 with link time reference

解决办法如下:

运行:

#pip install -U cryptography

Downloading/unpacking cryptography from https://pypi.python.org/packages/source/c/cryptography/cryptography-1.2.3.tar.gz#md5=5474d2b3e8c7555a60852e48d2743f85 Downloading cryptography-1.2.3.tar.gz (373kB): 373kB downloaded Running setup.py (path:/tmp/pip-build-moSGdh/cryptography/setup.py) egg_info for package cryptography

no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '*' found under directory 'vectors'

Requirement already up-to-date: idna>=2.0 in /usr/lib/python2.7/dist-packages (from cryptography) Downloading/unpacking pyasn1>=0.1.8 from https://pypi.python.org/packages/3.5/p/pyasn1/pyasn1-0.1.9-py2.py3-none-any.whl#md5=0122c4548f64510b24a35353c0837198 (from cryptography) Downloading pyasn1-0.1.9-py2.py3-none-any.whl Downloading/unpacking six>=1.4.1 from https://pypi.python.org/packages/py2.py3/s/six/six-1.10.0-py2.py3-none-any.whl#md5=3ab558cf5d4f7a72611d59a81a315dc8 (from cryptography) Downloading six-1.10.0-py2.py3-none-any.whl Downloading/unpacking setuptools>=1.0 from https://pypi.python.org/packages/3.5/s/setuptools/setuptools-20.2.2-py2.py3-none-any.whl#md5=97127baa80ab8ceb383e4490626be475 (from cryptography) Downloading setuptools-20.2.2-py2.py3-none-any.whl (508kB): 508kB downloaded Downloading/unpacking enum34 from https://pypi.python.org/packages/source/e/enum34/enum34-1.1.2.tar.gz#md5=025bb71b3f9d2fad15d0ee53e48dc873 (from cryptography) Downloading enum34-1.1.2.tar.gz (46kB): 46kB downloaded Running setup.py (path:/tmp/pip-build-moSGdh/enum34/setup.py) egg_info for package enum34

Downloading/unpacking ipaddress from https://pypi.python.org/packages/2.7/i/ipaddress/ipaddress-1.0.16-py27-none-any.whl#md5=ca35627d73f695d7dd8999b62a13323f (from cryptography) Downloading ipaddress-1.0.16-py27-none-any.whl Downloading/unpacking cffi>=1.4.1 (from cryptography) Downloading cffi-1.5.2.tar.gz (388kB): 388kB downloaded Running setup.py (path:/tmp/pip-build-moSGdh/cffi/setup.py) egg_info for package cffi

Requirement already up-to-date: pycparser in /usr/lib/python2.7/dist-packages (from cffi>=1.4.1->cryptography) Installing collected packages: cryptography, pyasn1, six, setuptools, enum34, ipaddress, cffi Found existing installation: cryptography 1.0.1 Not uninstalling cryptography at /usr/lib/python2.7/dist-packages, owned by OS Running setup.py install for cryptography

Installed /tmp/pip-build-moSGdh/cryptography/.eggs/cffi-1.5.2-py2.7-linux-x86_64.egg

no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '*' found under directory 'vectors'
generating cffi module 'build/temp.linux-x86_64-2.7/_padding.c'
generating cffi module 'build/temp.linux-x86_64-2.7/_constant_time.c'
generating cffi module 'build/temp.linux-x86_64-2.7/_openssl.c'
building '_openssl' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o -lssl -lcrypto -o build/lib.linux-x86_64-2.7/cryptography/hazmat/bindings/_openssl.so
building '_constant_time' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_constant_time.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_constant_time.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_constant_time.o -o build/lib.linux-x86_64-2.7/cryptography/hazmat/bindings/_constant_time.so
building '_padding' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_padding.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_padding.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_padding.o -o build/lib.linux-x86_64-2.7/cryptography/hazmat/bindings/_padding.so

Found existing installation: pyasn1 0.1.8 Not uninstalling pyasn1 at /usr/lib/python2.7/dist-packages, owned by OS Found existing installation: six 1.9.0 Not uninstalling six at /usr/lib/python2.7/dist-packages, owned by OS Found existing installation: setuptools 18.4 Not uninstalling setuptools at /usr/lib/python2.7/dist-packages, owned by OS Found existing installation: enum34 1.0.4 Not uninstalling enum34 at /usr/lib/python2.7/dist-packages, owned by OS Running setup.py install for enum34

Could not find .egg-info directory in install record for enum34 from https://pypi.python.org/packages/source/e/enum34/enum34-1.1.2.tar.gz#md5=025bb71b3f9d2fad15d0ee53e48dc873 in /usr/lib/python2.7/dist-packages (from cryptography) Found existing installation: ipaddress 1.0.14 Not uninstalling ipaddress at /usr/lib/python2.7/dist-packages, owned by OS Found existing installation: cffi 1.1.2 Not uninstalling cffi at /usr/lib/python2.7/dist-packages, owned by OS Running setup.py install for cffi building '_cffi_backend' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/c/_cffi_backend.o -lffi -o build/lib.linux-x86_64-2.7/_cffi_backend.so

Could not find .egg-info directory in install record for cffi>=1.4.1 (from cryptography) Successfully installed cryptography pyasn1 six setuptools enum34 ipaddress cffi Cleaning up...

再运行XX-Mini,正常!

#python proxy.py

Mar 15 16:02:39.629 - [DEBUG] network is ok, cost:261 ms Mar 15 16:02:39.637 - [INFO] SSL use version:TLSv1_2 Mar 15 16:02:39.639 - [INFO] load ip range file:/home/yuan/XX-mini-linux/ip_range.txt Mar 15 16:02:39.672 - [INFO] load google ip_list num:843, gws num:843 Mar 15 16:02:39.674 - [INFO] Adjust scan thread num from 50 to 25 Mar 15 16:02:39.689 - [DEBUG] ## GAEProxy set keep_running: True Mar 15 16:02:39.689 - [INFO] ------------------------------------------------------ Mar 15 16:02:39.689 - [INFO] Python Version : 2.7.10 Mar 15 16:02:39.689 - [INFO] OS : Dist:Ubuntu; Version:15.10; ID:wily Mar 15 16:02:39.689 - [INFO] Listen Address : 127.0.0.1:8087 Mar 15 16:02:39.690 - [INFO] GAE APPID : appid1|appid2 Mar 15 16:02:39.690 - [INFO] Pac Server : http://127.0.0.1:8086/proxy.pac

yeahwu commented 8 years ago

用的linux mint,没有出现报错,可能自带的库比较全面。等下试试ubuntu

xyuanmu commented 8 years ago

感谢提出解决方案! 看日志用的是系统自带的 OpenSSL 库,我测试的时候用的是 ubuntu 14.04,版本有点旧了。

yeahwu commented 8 years ago

俺也测试过,ubuntu 14.04,python2.7.6,是挺旧的,呵呵

jzp820927 commented 8 years ago

马上就可以用 ubuntu 16.04了,激动人心,等 16.04 等了2年了

fletchere commented 8 years ago

用上了arch后,其他的版本再好也只能排第二位了,不过还是说ubuntu 16.04值得一试。

mebest100 commented 8 years ago

linux发行版本根本没有最好之说,适合自己的才是最好的。 以前也有人争论到底freebcd还是gentoo才是最好的linux发行版本,这种争论根本毫无意义。 用的顺手用的舒服体验良好的才是对自己最好的版本,对于1000个人会有1000种答案,总之只有适合自己的才是最好的。

jzp820927 commented 8 years ago

确实,需求不一样,答案就不一样

wz7465 commented 8 years ago

ubuntu 14.04,python2.7.6报错如下: Traceback (most recent call last): File "proxy.py", line 53, in from OpenSSL import version as openssl_version File "//lib.egg/lib/OpenSSL/init.py", line 36, in ImportError: cannot import name crypto

用上面的解决办法pip install -U cryptography 又是一堆报错

xyuanmu commented 8 years ago

@wz7465 你是不是64位系统?手动安装 pyOpenSSL,自带的应该是32位的,Linux下python库32位和64位互不兼容。

wz7465 commented 8 years ago

是的,后来试了xx-net,安装了一堆依赖,也包括pyOpenSSL,就好了