title: Amazon Linux下解决*服务端EVP_CIPHER_CTX_cleanup() 函数报错
date: 2019-06-24 15:30:08
categories:
- Linux
tags: - shdowsocks
Amazon Linux下解决*服务端EVP_CIPHER_CTX_cleanup() 函数报错
Amazon Linux
的openssl
版本高于1.1.0以上版本,导致*
服务出现undefined symbol: EVP_CIPHER_CTX_cleanup
错误而无法启动。
Traceback (most recent call last):
File "/root/miniconda3/bin/ssserver", line 10, in <module>
sys.exit(main())
File "/root/miniconda3/lib/python3.7/site-packages/*/server.py", line 34, in main
config = shell.get_config(False)
File "/root/miniconda3/lib/python3.7/site-packages/*/shell.py", line 262, in get_config
check_config(config, is_local)
File "/root/miniconda3/lib/python3.7/site-packages/*/shell.py", line 124, in check_config
encrypt.try_cipher(config['password'], config['method'])
File "/root/miniconda3/lib/python3.7/site-packages/*/encrypt.py", line 44, in try_cipher
Encryptor(key, method)
File "/root/miniconda3/lib/python3.7/site-packages/*/encrypt.py", line 83, in __init__
random_string(self._method_info[1]))
File "/root/miniconda3/lib/python3.7/site-packages/*/encrypt.py", line 109, in get_cipher
return m[2](method, key, iv, op)
File "/root/miniconda3/lib/python3.7/site-packages/*/crypto/rc4_md5.py", line 33, in create_cipher
return openssl.OpenSSLCrypto(b'rc4', rc4_key, b'', op)
File "/root/miniconda3/lib/python3.7/site-packages/*/crypto/openssl.py", line 76, in __init__
load_openssl()
File "/root/miniconda3/lib/python3.7/site-packages/*/crypto/openssl.py", line 52, in load_openssl
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
File "/root/miniconda3/lib/python3.7/ctypes/__init__.py", line 369, in __getattr__
func = self.__getitem__(name)
File "/root/miniconda3/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /root/miniconda3/lib/python3.7/lib-dynload/../../libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
这是由于在openssl 1.1.0中废弃了 EVP_CIPHER_CTX_cleanup()
函数而引入了 EVE_CIPHER_CTX_reset()
函数所导致的:
EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result, EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared. EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset().
因此,可以通过将 EVP_CIPHER_CTX_cleanup()
函数替换为 EVP_CIPHER_CTX_reset()
函数来解决该问题。具体解决方法如下:
-
根据错误信息定位到文件/root/miniconda3/lib/python3.7/site-packages/*/crypto/openssl.py。
-
搜索 cleanup 并将其替换为 reset 。
[root]vi /root/miniconda3/lib/python3.7/site-packages/*/crypto/openssl.py
[root]/cleanup
不止一处,替换完。
- 重新启动 *, 该问题解决。