Symfony2& PayPal - cURL错误:14077410:SSL(sslv3警报握手失败)

时间:2016-01-31 18:32:43

标签: php symfony ssl curl paypal

我试图连接到Paypal的沙盒服务器。为此,我使用了JMSPaymentCoreBundle和JMSPaypalCoreBundle。

但是当我尝试连接异常时,会抛出: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 I'v got that

中添加curl_setopt($curl, CURLOPT_SSLVERSION,6);

when I don't

1 个答案:

答案 0 :(得分:0)

您是否正在针对PayPal Sandbox API端点进行测试? PayPal昨晚升级了他们的Sandbox API端点,要求TLS 1.2并提供(仅)SHA256签名证书。

更多细节在这里和这里。

根据它的声音,你要么试图强制执行除TLS 1.2之外的其他东西(可能),要么你的openssl libs太旧了,他们不支持TLS 1.2(任何低于OpenSSL 1.0的东西)。 1c,太不可能了。)

您可能想尝试从SDK运行TlsCheck.php