Skip to content
Snippets Groups Projects
Commit c6b07327 authored by Kevin Saliou's avatar Kevin Saliou
Browse files

Merge pull request #141 from benoitvidis/curlopt_sslversion

Add the ability to force CURLOPT_SSLVERSION
parents 697b9a16 be4fb51c
Branches
Tags v1.5.5
No related merge requests found
......@@ -58,6 +58,11 @@ class Client
*/
private $checkSslHost = false;
/**
* @var int
*/
private $sslVersion = 0;
/**
* @var bool Flag to determine authentication method
*/
......@@ -296,6 +301,31 @@ class Client
return $this->checkSslHost;
}
/**
* Forces the SSL/TLS version to use.
* @see http://curl.haxx.se/libcurl/c/CURLOPT_SSLVERSION.html
*
* @param int $sslVersion
*
* @return Client
*/
public function setSslVersion($sslVersion = 0)
{
$this->sslVersion = $sslVersion;
return $this;
}
/**
* Returns the SSL Version used.
*
* @return int
*/
public function getSslVersion()
{
return $this->sslVersion;
}
/**
* Turns on/off http auth.
*
......@@ -455,6 +485,7 @@ class Client
if (80 !== $this->getPort()) {
$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->checkSslCertificate);
$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->checkSslHost);
$this->setCurlOption(CURLOPT_SSLVERSION, $this->sslVersion);
}
// Additional request headers
......
......@@ -140,6 +140,20 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($client->getCheckSslHost());
}
/**
* @covers Redmine\Client
* @test
*/
public function testGetAndSetSSlVersion()
{
$client = new Client('http://test.local', 'asdf');
$this->assertInstanceOf('Redmine\Client', $client->setSslVersion());
$this->assertSame(0, $client->getSslVersion());
$this->assertInstanceOf('Redmine\Client', $client->setSslVersion(6));
$this->assertSame(6, $client->getSslVersion());
}
/**
* @covers Redmine\Client
* @test
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment