2016-01-31 79 views
2

我試圖連接到貝寶的沙箱服務器。爲此,我使用JMSPaymentCoreBundle和JMSPaypalCoreBundle。Symfony2&PayPal - cURL錯誤:14077410:SSL(sslv3警報握手失敗)

但是,當我試圖連接異常被拋出:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

我的Symfony的版本是2.7.9。我的curl版本是7.43.0,而OpenSSL的版本是1.0.2f。

我在網上尋找答案,它看起來像現在cURL請求使用TLS 1.2爲了使用PayPal沙箱。於是我說: curl_setopt($curl, CURLOPT_SSLVERSION,6);(這是TLS 1.2) 在vendor/jms/payment-paypal-bundle/JMS/Payment/PaypalBundle/Client/Client.php

但現在我已經得到了以下錯誤:cURL Error: Unsupported SSL protocol version

感謝您的幫助! (和抱歉,我的英語水平)

編輯:所以錯誤似乎來自以下幾個部分

在我的控制器:

$instruction = $reservation->getPaymentInstruction(); 
if (null === $pendingTransaction = $instruction->getPendingTransaction()) { 
    $payment = $this->ppc->createPayment($instruction->getId(), $instruction->getAmount() - $instruction->getDepositedAmount()); 
} else { 
    $payment = $pendingTransaction->getPayment(); 
} 

$result = $this->ppc->approveAndDeposit($payment->getId(), $payment->getTargetAmount()); 
if (Result::STATUS_PENDING === $result->getStatus()) { 
    $ex = $result->getPluginException(); 

    if ($ex instanceof ActionRequiredException) { 
      $action = $ex->getAction(); 

      if ($action instanceof VisitUrl) { 
       return $this->redirect($action->getUrl()); 
      } 

      throw $ex; 
     } 
} else if (Result::STATUS_SUCCESS !== $result->getStatus()) { 
    throw new \RuntimeException('Transaction was not successful: '.$result->getReasonCode()); 
} 

在我的供應商:(vendor/jms/payment-paypal-bundle/JMS/Payment/PaypalBundle/Client/Client.php

public function request(Request $request) 
{ 
    if (!extension_loaded('curl')) { 
     throw new \RuntimeException('The cURL extension must be loaded.'); 
    } 

    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt_array($curl, $this->curlOptions); 
    curl_setopt($curl, CURLOPT_URL, $request->getUri()); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($curl, CURLOPT_HEADER, true); 
// Try but did not worl: curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST,  'TLSv1'); 
    curl_setopt($curl, CURLOPT_SSLVERSION,6); // What i also add but error with my SSL protocol version not supported 

etc. 

當我在Client.php中添加curl_setopt($curl, CURLOPT_SSLVERSION,6);I'v got that

when I don't

+0

您可以發佈您的代碼中遇到問題的位置嗎? – Demitrian

回答

0

您是否針對PayPal Sandbox API端點進行測試? PayPal昨晚將其Sandbox API端點升級爲需要TLS 1.2並提供(僅)SHA256簽名證書。

更多細節在這裏和這裏。由於它的聲音,你要麼嘗試執行除TLS 1.2之外的其他內容(可能),或者你的openssl庫很舊,它們不支持TLS 1.2(任何低於OpenSSL 1.0.1c的東西,所以不太可能)。

您可能想嘗試運行SDK中的TlsCheck.php

+0

謝謝!我要去看看!只是,我想你忘了鏈接? –

+0

https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=zh_CN – hsb1007