报错信息:
root@ip-172-31-26-125:~# ssserver -c /xxx.json -d restart
INFO: loading config from /root/shadowsocks-20211113.json
2024-03-12 00:46:40 INFO loading libcrypto from libcrypto.so.1.1
Traceback (most recent call last):
File "/usr/local/bin/ssserver", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/server.py", line 34, in main
config = shell.get_config(False)
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/shell.py", line 262, in get_config
check_config(config, is_local)
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/shell.py", line 124, in check_config
encrypt.try_cipher(config['password'], config['method'])
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/encrypt.py", line 44, in try_cipher
Encryptor(key, method)
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/encrypt.py", line 82, in __init__
self.cipher = self.get_cipher(key, method, 1,
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/encrypt.py", line 109, in get_cipher
return m[2](method, key, iv, op)
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/crypto/openssl.py", line 76, in __init__
load_openssl()
File "/usr/local/lib/python3.8/dist-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
File "/usr/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib/x86_64-linux-gnu/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()
函数来解决该问题。具体解决方法如下:
1、根据错误信息定位到文件 /home/feng/.local/lib/python3.6/site-packages/shadowsocks/crypto/openssl.py 。
2、搜索 cleanup 并将其替换为 reset 。
3、重新启动 shadowsocks, 该问题解决。
解决方案:
sed -i 's/EVP_CIPHER_CTX_cleanup/EVP_CIPHER_CTX_reset/g' /usr/local/lib/python3.8/dist-packages/shadowsocks/crypto/openssl.py
Solved by replacing all (total 2) the EVP_CIPHER_CTX_cleanup()
functions to EVP_CIPHER_CTX_reset()
in the openssl.py file. With the following command:
edit /usr/local/lib/python3.8/dist-packages/shadowsocks/crypto/openssl.py
1 | |
And restart the Shadowsocks server. Done!