尝试通过TLS提出请求时出现以下错误
File "C:\Python27\lib\site-packages\requests-2.10.0-py2.7.egg\requests\api.py", line 111, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.10.0-py2.7.egg\requests\api.py", line 57, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.10.0-py2.7.egg\requests\sessions.py", line 476, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests-2.10.0-py2.7.egg\requests\sessions.py", line 586, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.10.0-py2.7.egg\requests\adapters.py", line 491, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)
所以也许我提出的要求也是错的? 这就是我的要求。
import json
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
import ssl
class myAdapter(HTTPAdapter):
""""Transport adapter" that allows us to use SSLv3."""
def init_poolmanager(self, connections, maxsize, block=False):
self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize,block=block, ssl_version=ssl.PROTOCOL_TLSv1_2)
s = requests.Session()
jsondata = json.dumps({
"wsRequestHeaderV2": {
},
"requestData": {})
headers = {'content-type': 'application/json'}
payload = {'json_payload':jsondata}
r = s.post('HTTP://URL', data=payload,headers=headers,verify='LALA.PEM')
print r