Python paypalrestsdk和SSL错误

时间:2014-12-08 06:55:54

标签: python ssl paypal paypal-rest-sdk

我正在尝试使用Python和paypalrestsdk提取PayPal订单信息。

出于某种原因,我收到的证书错误对我来说没有意义。

payment_history = paypalrestsdk.Payment.all({"count": 10}, api=PayPal_key.Key_api())
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/resource.py", line 137, in all
    response = api.get(url)
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 222, in get
    return self.request(util.join_url(self.endpoint, action), 'GET', headers=headers or {})
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 135, in request
    http_headers = util.merge_dict(self.headers(refresh_token=refresh_token), headers or {})
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 205, in headers
    token_hash = self.get_token_hash(refresh_token=refresh_token)
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 98, in get_token_hash
    "Accept": "application/json", "User-Agent": self.user_agent
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 161, in http_call
    response = requests.request(method, url, proxies=self.proxies, **kwargs)
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/api.py", line 49, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

我检查了paypal.com证书:

requests.get('https://paypal.com', verify=True)

得到了:

<Response [200]>

有人可以帮忙解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

paypal.com提供的证书与其API端点提供的证书不同,因此您的测试:

requests.get('https://paypal.com', verify=True)

..没有透露您在尝试使用其API时遇到的问题。

如果您仍然遇到问题,我建议您查看upgrading the underlying version of OpenSSL以确保您使用支持TLS 1.2 PayPal's API endpoints require的版本。