Fixed Curl Options for NSS

This commit is contained in:
japatel
2014-11-12 15:25:33 -06:00
parent dad86f2374
commit 2c3f25bd29
4 changed files with 40 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ class PPConstants
{
const SDK_NAME = 'PayPal-PHP-SDK';
const SDK_VERSION = '0.14.1';
const SDK_VERSION = '0.14.2';
const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/";
const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect";

View File

@@ -32,7 +32,6 @@ class PPHttpConfig
//Adding it like this for backward compatibility with older versions of curl
);
const HEADER_SEPARATOR = ';';
const HTTP_GET = 'GET';
const HTTP_POST = 'POST';
@@ -61,6 +60,13 @@ class PPHttpConfig
$this->url = $url;
$this->method = $method;
$this->curlOptions = self::$defaultCurlOptions;
// Update the Cipher List based on OpenSSL or NSS settings
$curl = curl_version();
$sslVersion = isset($curl['ssl_version']) ? $curl['ssl_version'] : '';
if (substr_compare($sslVersion, "NSS/", 0, strlen("NSS/")) === 0) {
//Remove the Cipher List for NSS
$this->removeCurlOption(CURLOPT_SSL_CIPHER_LIST);
}
}
/**
@@ -167,13 +173,23 @@ class PPHttpConfig
* Add Curl Option
*
* @param string $name
* @param mixed $value
* @param mixed $value
*/
public function addCurlOption($name, $value)
{
$this->curlOptions[$name] = $value;
}
/**
* Removes a curl option from the list
*
* @param $name
*/
public function removeCurlOption($name)
{
unset($this->curlOptions[$name]);
}
/**
* Set Curl Options. Overrides all curl options
*

View File

@@ -1,5 +1,9 @@
PayPal PHP SDK release notes
============================
v0.14.2
----
* Quick Patch to Unset Cipher List for NSS
v0.14.1
----
* Updated HttpConfig to use TLSv1 as Cipher List

View File

@@ -1,11 +1,14 @@
<?php
namespace PayPal\Test\Core;
use PayPal\Core\PPHttpConfig;
/**
* Test class for PPAPIService.
*
*/
class PPHttpConfigTest extends PHPUnit_Framework_TestCase
class PPHttpConfigTest extends \PHPUnit_Framework_TestCase
{
protected $object;
@@ -72,6 +75,19 @@ class PPHttpConfigTest extends PHPUnit_Framework_TestCase
$this->assertEquals('v', $curlOpts['k']);
}
public function testRemoveCurlOpts()
{
$o = new PPHttpConfig();
$o->setCurlOptions(array('k' => 'v'));
$curlOpts = $o->getCurlOptions();
$this->assertEquals(1, count($curlOpts));
$this->assertEquals('v', $curlOpts['k']);
$o->removeCurlOption('k');
$curlOpts = $o->getCurlOptions();
$this->assertEquals(0, count($curlOpts));
}
/**
* @test
*/