sslv3警报握手失败(_ssl.c:590)?


0

这是我的代码:

def test(request):
paypalrestsdk.configure({
  "mode": "security-test-sandbox",
    "client_id": "XXXXXXX-XXXX-XXXX-XXXX",
    "client_secret": "XXXXXXX-XXXX-XXXX-XXXX"  })

payment = paypalrestsdk.Payment({
  "intent": "sale",
  "payer": {
    "payment_method": "credit_card",
    "funding_instruments": [{
      "credit_card": {
        "type": "visa",
        "number": "4417119669820331",
        "expire_month": "11",
        "expire_year": "2018",
        "cvv2": "874",
        "first_name": "Joe",
        "last_name": "Shopper" }}]},
  "transactions": [{
    "item_list": {
      "items": [{
        "name": "item",
        "sku": "item",
        "price": "1.00",
        "currency": "USD",
        "quantity": 1 }]},
    "amount": {
      "total": "1.00",
      "currency": "USD" },
    "description": "This is the payment transaction description." }]})

if payment.create():
  print("Payment created successfully")
else:
  print(payment.error)
return render(request, "test.html")

执行命令payment.create()时,它出错:[SSL:SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3警报握手失败(_ssl.c:590)。我正在使用Mac。请告诉我为什么?

Answers:


3

我遇到了同样的问题,这就是我发现的以及我如何修复:

Apple提供的Python版本在openssl方面已经过时了。您可以通过进入终端来测试您的版本:

python
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 0.9.8zh 14 Jan 2016

以上是坏版本。一个解决方法是安装新版本的python。最简单的方法可能就是使用家酿 这里描述

下面类似于你应该看到的升级版本的python。然后paypalrestsdk将工作。

python
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2h  3 May 2016
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.