我有一台带有OpenNao发行版的LINUX机器(基于GENTOO)。这台机器有Python 2.7.3。我没有root权限。 您可以从以下链接下载Virtualbox(OpenNAO OS VirtualBox 2.1.2)中的可执行映像(您可能需要创建一个帐户):
我的问题是我正在尝试向具有TLS 1.2的AZURE服务器发出呼叫请求,其代码如下:
import requests
url = "www.example-url.com" # it is not a real url
querystring = {"key":"value",}
headers = {'token': "4bfd740f482d48a3a894445eb6a85a83",'Username': "user",'Password':"password"}
#response = requests.request("GET", url, headers=headers, params=querystring)
response = requests.get(url, headers=headers, params=querystring, timeout=30)
我收到以下错误:
/var/persistent/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/var/persistent/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
Traceback (most recent call last):
File "heathrowFI-3.py", line 33, in <module>
response = requests.get(url, headers=headers, params=querystring, timeout=30)
File "/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
我尝试使用TLS 1.2在其他计算机(Windows,Ubuntu)上发出请求,结果没问题。 为了获得每台机器的TLS版本,我使用了以下命令
python -c "import json, urllib2; print json.load (urllib2.urlopen ('https://www.howsmyssl.com/a/check')) ['tls_version']"
使用python 2.7和TLS 1.2的WINDOWS机器:请求结果正常。
使用python 2.7和TLS 1.2的UBUNTU机器:请求结果正常。
我认为错误是由NaoQi使用的SSL的TLS 1.0版本引起的。我发出请求的服务器是Azure,仅支持TLS 1.2。 我在浏览器中检查了它的TLS:
我无法更新Python(我没有root权限)。
请知道我如何将请求发送到服务器?我应该在NAOQI机器上更新TLS 1.0到TLS 1.2吗?你知道如何更新吗?。
欢迎任何帮助或建议。
提前致谢,问候。