Ubuntu 18.04 下解决 shadowsocks 服务报错问题

2020/08/0812:01:25Ubuntu 18.04 下解决 shadowsocks 服务报错问题已关闭评论

1. 报错内容

启动时报错如下:

Traceback (most recent call last):
File "/usr/local/bin/sslocal", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/local.py", line 39, in main
config = shell.get_config(True)
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/shell.py", line 262, in get_config
check_config(config, is_local)
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/shell.py", line 124, in check_config
encrypt.try_cipher(config['password'], config['method'])
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/encrypt.py", line 44, in try_cipher
Encryptor(key, method)
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/encrypt.py", line 83, in init
random_string(self._method_info[1]))
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/encrypt.py", line 109, in get_cipher
return m[2](method, key, iv, op)
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/crypto/openssl.py", line 76, in init
load_openssl()
File "/usr/local/lib/python3.6/dist-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
File "/usr/lib/python3.6/ctypes/init.py", line 361, in getattr
func = self.getitem(name)
File "/usr/lib/python3.6/ctypes/init.py", line 366, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup

2、原因

由于Ubuntu 18中由于升级 openssl 至1.1.0以上版本导致的 shadowsocks 服务出现 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() 函数来解决该问题。具体解决方法如下:

  • 根据错误信息定位到文件 /home/feng/.local/lib/python3.6/site-packages/shadowsocks/crypto/openssl.py 。

  • 搜索 cleanup 并将其替换为 reset 。

  • 重新启动 shadowsocks, 该问题解决。

  • 微信扫码赞助
  • weinxin
  • 支付宝赞助
  • weinxin