ly0 / baidupcsapi

百度网盘api
MIT License
1.21k stars 234 forks source link

why ssl error #16

Closed boyzhujian closed 8 years ago

boyzhujian commented 9 years ago

when first deploy on remote server, encounter this,I never change anything and I'am sure password is ok. request version is requests (2.8.1) requests-toolbelt (0.4.0)

super(PCS, self).init(username, password, api_template, captcha_func=captcha_callback) File "/home/wwwroot/yun.4moviescheduling.com/api.py", line 135, in init self._initiate() File "/home/wwwroot/yun.4moviescheduling.com/api.py", line 183, in _initiate self.user['token'] = self._get_token() File "/home/wwwroot/yun.4moviescheduling.com/api.py", line 210, in _get_token 'https://passport.baidu.com/v2/api/?getapi&tpl=mn&apiver=v3&class=login&tt=%s&logintype=dialogLogin&callback=0' % int(time.time())).text.replace('\'', '\"') File "/usr/local/lib/python2.7/dist-packages/requests-2.8.1-py2.7.egg/requests/sessions.py", line 480, in get return self.request('GET', url, _kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.8.1-py2.7.egg/requests/sessions.py", line 468, in request resp = self.send(prep, _send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.8.1-py2.7.egg/requests/sessions.py", line 576, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.8.1-py2.7.egg/requests/adapters.py", line 447, in send raise SSLError(e, request=request) requests.exceptions.SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

ly0 commented 9 years ago

Please try one of the following ways:

  1. Downgrade your requests to 2.6.X
  2. Change https://github.com/ly0/baidupcsapi/blob/master/baidupcsapi/api.py#L209 ret = self.session.get( 'https://passport.baidu.com/v2/api/?getapi&tpl=mn&apiver=v3&class=login&tt=%s&logintype=dialogLogin&callback=0' % int(time.time())).text.replace('\'', '\"') to ret = self.session.get( 'https://passport.baidu.com/v2/api/?getapi&tpl=mn&apiver=v3&class=login&tt=%s&logintype=dialogLogin&callback=0' % int(time.time()), verify=False).text.replace('\'', '\"')
xm0625 commented 8 years ago

关闭ssl证书校验可以解决,也方便用mitmproxy调试接口.

lilydjwg commented 8 years ago

@xm0625 也方便被攻击。 正确的姿势是放弃使用 Python <= 2.7.8。

boyzhujian commented 8 years ago

Thank you all