简体   繁体   English

PayPal-PHP-SDK中不支持的SSL协议版本

[英]Unsupported SSL protocol version in PayPal-PHP-SDK

I used this snippet in my application in Symfony2 + KMJPayPalBridgeBundle 我在Symfony2 + KMJPayPalBridgeBundle的应用程序中使用了此代码段

http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html

Few months ago it was all good but now I'm getting "Unsupported SSL protocol version" error. 几个月前一切都很好,但是现在我收到“不支持的SSL协议版本”错误。

Controller code 控制器代码

public function testAction()
{
    $paypal = $this->get('paypal');
    $apiContext = $paypal->getApiContext();

    $payer = new Payer(); 
    $payer->setPaymentMethod("paypal");

    $item1 = new Item(); 
    $item1->setName('Ground Coffee 40 oz') 
            ->setCurrency('USD') 
            ->setQuantity(1) 
            ->setSku("123123"); // Similar to `item_number` in Classic API ->setPrice(7.5); 
    $item2 = new Item(); 
    $item2->setName('Granola bars') 
            ->setCurrency('USD') 
            ->setQuantity(5) 
            ->setSku("321321"); // Similar to `item_number` in Classic API ->setPrice(2);

    $itemList = new ItemList(); 
    $itemList->setItems(array($item1, $item2));

    $details = new Details(); 
    $details->setShipping(1.2) 
            ->setTax(1.3) 
            ->setSubtotal(17.50);
    $amount = new Amount(); 
    $amount->setCurrency("USD") 
            ->setTotal(20) 
            ->setDetails($details);

    $transaction = new Transaction(); 
    $transaction->setAmount($amount) 
                ->setItemList($itemList) 
                ->setDescription("Payment description") 
                ->setInvoiceNumber(uniqid());

    $baseUrl = "http://development.local"; 
    $redirectUrls = new RedirectUrls(); 
    $redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true") 
                ->setCancelUrl("$baseUrl/ExecutePayment.php?success=false");

    $payment = new Payment(); 
    $payment->setIntent("sale") 
            ->setPayer($payer) 
            ->setRedirectUrls($redirectUrls) 
            ->setTransactions(array($transaction));

    $request = clone $payment;
    try { $payment->create($apiContext); } catch (Exception $ex) {
        ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", 
                                    "Payment", null, $request, $ex); exit(1); 
    }
    $approvalUrl = $payment->getApprovalLink();
    ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", 
                                    "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment); 

    return array();
}

Are you testing against the PayPal Sandbox API endpoints? 您是否正在针对PayPal Sandbox API端点进行测试?
PayPal upgraded their Sandbox API endpoints last night to require TLS 1.2 and offering (only) a SHA256-signed certificate. PayPal昨晚升级了其Sandbox API端点,以要求TLS 1.2并(仅)提供SHA256签名的证书。

More details are here and here . 更多细节在这里这里

By the sounds of it, you're either trying to enforce something other than TLS 1.2 (likely), or your openssl libs are so old, they don't support TLS 1.2 (anything below OpenSSL 1.0.1c, so unlikely). 听起来,您正在尝试强制执行除TLS 1.2之外的其他操作,或者您的openssl库太旧了,它们不支持TLS 1.2(低于OpenSSL 1.0.1c的任何东西,所以可能性不大)。

You may want to try running TlsCheck.php from the SDK 您可能要尝试从SDK运行TlsCheck.php

There was an upgrade of the SDK: SDK进行了升级:

https://github.com/paypal/PayPal-PHP-SDK/issues/474 https://github.com/paypal/PayPal-PHP-SDK/issues/474

with a checklist of current system requirments. 以及当前系统要求的清单。

In my case it was different CLI PHP and different on server that caused an issue. 在我的情况下,导致问题的原因是不同的CLI PHP和服务器上的不同。

PHP uses the system supplied CURL library. PHP使用系统提供的CURL库。 Version 7.34.0 or later is required. 需要版本7.34.0或更高版本。 -- From the second link. -从第二个链接。

I'm running into the same issue, and followed the update guides. 我遇到了同样的问题,并遵循了更新指南。

I figured out that php is still using curl version 7.19.0 Even when I run curl --version, I get 7.46.0. 我发现php仍在使用curl版本7.19.0,即使我运行curl --version时,我也得到7.46.0。 Working with server admin to recompile php. 与服务器管理员一起重新编译php。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM