Windows sybsystem for LinuxのSSL/TLSがKasperskyに拒まれる
状況
Windows 10でWSL上のUbuntu 18.04 LTS / 16.04 LTSを使用している環境で、Python環境を作ろうとするとpip等がSSL関連のエラーを返す。ca-certificatesは導入済みで、ping等は疎通する。アンチウイルスソフトとしてKaspersky Free(19.0.0.1088)が導入されている。
curl
USER@local:~$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to bootstrap.pypa.io:443
wget
USER@local:~$ wget https://bootstrap.pypa.io/get-pip.py
--2018-12-12 17:12:42-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.88.175, 2a04:4e42:15::175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.88.175|:443... connected.
Unable to establish SSL connection.
仕方がないのでapt-getでインストールする
USER@local:~$ sudo apt-get install python3-pip
インストールは出来るのだが。。。
USER@local:~$ pip3 -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
検索をかけてみるとやはり通信出来ない
USER@local:~$ pip3 search pip
Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 852, in _validate_conn
conn.connect()
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connection.py", line 326, in connect
ssl_context=context)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/share/python-wheels/six-1.11.0-py2.py3-none-any.whl/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py", line 852, in _validate_conn
conn.connect()
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connection.py", line 326, in connect
ssl_context=context)
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(0, 'Error'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/search.py", line 45, in run
pypi_hits = self.search(query, options)
File "/usr/lib/python3/dist-packages/pip/commands/search.py", line 62, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "/usr/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/usr/lib/python3/dist-packages/pip/download.py", line 775, in request
headers=headers, stream=True)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(0, 'Error'))
結論から言うとKasperskyの問題
タスクトレイのKasperskyアイコンを右クリックして、settingsを選び、AdditionalからNetworkへ進む。
その中に Encrypted connections scanning というグループがあるので、「 Do not scan encrypted connections 」を選択する。
KasperskyのEncrypted connections scanning停止後は通信できるようになる
USER@local:~$ pip3 search pip
pip-utils (0.0.6) - Helper utilities for pip
pip-additions (0.2) - Additional Pip Utilities
pip-hello (0.0.1) - pip install test
pip-save (0.2.0) - A wrapper around pip to add `npm --save` style functionality to pip
pip-api (0.0.4) - The official unofficial pip API
pip-reqs (0.6) - Helpers for dealing with pip requirements
...以下略