Merge pull request #1396 from akkie/disable-ssl-verification

Allow to disable SSL verification
This commit is contained in:
wing328 2015-10-16 21:08:31 +08:00
commit a2fda604f8
2 changed files with 124 additions and 86 deletions

View File

@ -165,6 +165,12 @@ class ApiClient
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// disable SSL verification, if needed
if ($this->config->getSSLVerification() == false) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
}
if (! empty($queryParams)) { if (! empty($queryParams)) {
$url = ($url . '?' . http_build_query($queryParams)); $url = ($url . '?' . http_build_query($queryParams));
} }

View File

@ -126,6 +126,15 @@ class Configuration
*/ */
protected $tempFolderPath; protected $tempFolderPath;
/**
* Indicates if SSL verification should be enabled or disabled.
*
* This is useful if the host uses a self-signed SSL certificate.
*
* @var boolean True if the certificate should be validated, false otherwise.
*/
protected $sslVerification = true;
/** /**
* Constructor * Constructor
*/ */
@ -418,6 +427,29 @@ class Configuration
return $this->tempFolderPath; return $this->tempFolderPath;
} }
/**
* Sets if SSL verification should be enabled or disabled
*
* @param boolean $sslVerification True if the certificate should be validated, false otherwise
*
* @return Configuration
*/
public function setSSLVerification($sslVerification)
{
$this->sslVerification = $sslVerification;
return $this;
}
/**
* Gets if SSL verification should be enabled or disabled
*
* @return boolean True if the certificate should be validated, false otherwise
*/
public function getSSLVerification()
{
return $this->sslVerification;
}
/** /**
* Gets the default configuration instance * Gets the default configuration instance
* *