mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 02:11:45 +01:00
ConnectionConfiguration - add $verifySslCertificate property - if is set to true, the SSL certificate verification is turned on, otherwise - turned off
It's useful while running application with custom, non-official SSL certificate, e.g. while development process.
This commit is contained in:
@@ -59,15 +59,26 @@ class ConnectionConfiguration
|
||||
*/
|
||||
private $debugMode = false;
|
||||
|
||||
/**
|
||||
* If is set to true, the SSL certificate verification is turned on. Otherwise - turned off.
|
||||
* It's useful while running application with custom, non-official SSL certificate, e.g. while development process.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $verifySslCertificate = true;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $baseUrl Base url. Protocol & domain.
|
||||
* @param string $username Name of user used to authenticate to LimeSurvey
|
||||
* @param string $password Password used to authenticate to LimeSurvey
|
||||
* @param bool $debugMode (optional) If is set to true, the "debug" mode is turned on. Otherwise - turned off.
|
||||
* @param bool $debugMode (optional) If is set to true, the "debug" mode is turned on. Otherwise -
|
||||
* turned off.
|
||||
* @param bool $verifySslCertificate (optional) If is set to true, the SSL certificate verification is turned
|
||||
* on. Otherwise - turned off.
|
||||
*/
|
||||
public function __construct($baseUrl, $username, $password, $debugMode = false)
|
||||
public function __construct($baseUrl, $username, $password, $debugMode = false, $verifySslCertificate = true)
|
||||
{
|
||||
$this
|
||||
->setBaseUrl($baseUrl)
|
||||
@@ -201,6 +212,30 @@ class ConnectionConfiguration
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if the SSL certificate verification is turned on
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVerifySslCertificateOn()
|
||||
{
|
||||
return $this->verifySslCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets information if the SSL certificate verification is turned on
|
||||
*
|
||||
* @param bool $verifySslCertificate (optional) If is set to true, the SSL certificate verification is turned on.
|
||||
* Otherwise - turned off.
|
||||
* @return $this
|
||||
*/
|
||||
public function setVerifySslCertificate($verifySslCertificate = true)
|
||||
{
|
||||
$this->verifySslCertificate = $verifySslCertificate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* Additional / extra methods (neither getters, nor setters)
|
||||
|
||||
@@ -90,6 +90,16 @@ class JsonRpcClientManager
|
||||
->getHttpClient()
|
||||
->withDebug();
|
||||
}
|
||||
|
||||
/*
|
||||
* The SSL certificate verification is turned off?
|
||||
*/
|
||||
if (!$this->connectionConfiguration->isVerifySslCertificateOn()) {
|
||||
$this
|
||||
->rpcClient
|
||||
->getHttpClient()
|
||||
->withoutSslVerification();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->rpcClient;
|
||||
|
||||
@@ -31,7 +31,7 @@ class ConnectionConfigurationTest extends BaseTestCase
|
||||
|
||||
public function testConstructorVisibilityAndArguments()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(ConnectionConfiguration::class, OopVisibilityType::IS_PUBLIC, 4, 3);
|
||||
static::assertConstructorVisibilityAndArguments(ConnectionConfiguration::class, OopVisibilityType::IS_PUBLIC, 5, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,6 +101,18 @@ class ConnectionConfigurationTest extends BaseTestCase
|
||||
static::assertTrue($this->simpleConfiguration->isDebugModeOn());
|
||||
}
|
||||
|
||||
public function testSetVerifySslCertificate()
|
||||
{
|
||||
$this->simpleConfiguration->setVerifySslCertificate();
|
||||
static::assertTrue($this->simpleConfiguration->isVerifySslCertificateOn());
|
||||
|
||||
$this->simpleConfiguration->setVerifySslCertificate(false);
|
||||
static::assertFalse($this->simpleConfiguration->isVerifySslCertificateOn());
|
||||
|
||||
$this->simpleConfiguration->setVerifySslCertificate(true);
|
||||
static::assertTrue($this->simpleConfiguration->isVerifySslCertificateOn());
|
||||
}
|
||||
|
||||
public function testGetFullUrl()
|
||||
{
|
||||
$this->simpleConfiguration->setRemoteControlUrl('lorem/ipsum');
|
||||
|
||||
Reference in New Issue
Block a user