在尝试通过box.net api v2.0
获取身份验证令牌时,查找有关SSL错误的一些信息。
我正在使用Python 2.7,OpenSSL 1.0.1c和requests
库。
payload = {"action":"get_auth_token", "api_key":self.box_apikey, "ticket":self.box_ticket['status'], "verify":False}
r = requests.get(self.box_secure_endpoint+"rest", params=payload)
File "/usr/lib/python2.7/site-packages/requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/safe_mode.py", line 39, in wrapped
return function(method, url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/api.py", line 51, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/usr/lib/python2.7/site-packages/requests/models.py", line 641, in send
raise SSLError(e)
requests.exceptions.SSLError: _ssl.c:316: Invalid SSL protocol variant specified.
注意:
requests
lib,看看是否有一些关于SSL ver请求功能的工作。答案 0 :(得分:0)
您看到此错误是因为您在请求中将verify
参数作为URL参数发送,即您实际访问的网址是
https://api.box.com/1.0/rest?action=get_auth_token&api_key=APIKEY&ticket=ticket&verify=False
验证应作为关键字参数发送,并实际调用请求获取函数,即
r = requests.get(self.box_secure_endpoint+"rest", params=payload, verify=True)
答案 1 :(得分:0)
问题导致验证服务器ssl版本支持(explicity ssl.PROTOCOL_SSLv3 | http://docs.python.org/2.7/library/ssl.html#ssl.wrap_socket)。
我要将请求转发给lib devs或创建补丁以启用显式指定协议的功能。
感谢您的帮助。 :)