更新OpenSSL库至最新版本导致sss服务无法启动

作者:Matrix 发布时间:2017年4月16日星期日 分类:

ubuntu升级openssl库到OpenssL 1.1.0e版本,过程倒还好,到底还是成功了。但是reboot重启系统之后发现ss服务无法打开,这可是目前我唯一的科学电梯啊。
不过还好找到报错信息有解决办法。

>ssserver --version
shadowsocks 2.8.2 版本

报错:
root@root-VM:/usr/local/bin# ./ssserver  -c /etc/shadowsocks.json -d start
INFO: loading config from /etc/shadowsocks.json
2017-04-16 19:05:10 INFO     loading libcrypto from libcrypto.so.1.1
Traceback (most recent call last):
  File "./ssserver", line 9, in <module>
    load_entry_point('shadowsocks==2.8.2', 'console_scripts', 'ssserver')()
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/server.py", line 34, in main
    config = shell.get_config(False)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py", line 262, in get_config
    check_config(config, is_local)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py", line 124, in check_config
    encrypt.try_cipher(config['password'], config['method'])
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 44, in try_cipher
    Encryptor(key, method)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 83, in __init__
    random_string(self._method_info[1]))
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 109, in get_cipher
    return m[2](method, key, iv, op)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py", line 76, in __init__
    load_openssl()
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
    libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/ssl/lib/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup

说到底都是升级openssl导致无法使用,旧版EVP_CIPHER_CTX_cleanup函数被弃用改为EVP_CIPHER_CTX_reset

办法

定位到/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py文件:
修改52,111行处的EVP_CIPHER_CTX_cleanupEVP_CIPHER_CTX_reset 重启服务,解决。

实际情况根据自己的ss版本查找修改相关文件

参考:http://blog.csdn.net/blackfrog_unique/article/details/60320737

PEACE