Skip to content

Commit

Permalink
Added an option to disable CURLOPT_SSLVERIFYPEER to make it work with…
Browse files Browse the repository at this point in the history
… self-signed certificates.
  • Loading branch information
Jens Jahnke committed Jun 9, 2011
1 parent 53aed70 commit 893b127
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Connection {
private $cookies = array();
private $debug_verbose = FALSE; // Set to TRUE to enable verbose logging of curl messages.
private $user_agent = 'Mozilla/5.0'; // Use this as user agent string.
private $verify_ssl = TRUE;

public function __construct($url, $login, $password) {
$this->http = curl_init();
Expand All @@ -28,6 +29,7 @@ protected function _login($login, $password) {
curl_setopt($this->http, CURLOPT_URL, $this->base_url . '/user/login?login='. urlencode($login) .'&password='. urlencode($password));
curl_setopt($this->http, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->http, CURLOPT_HEADER, TRUE);
curl_setopt($this->http, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
curl_setopt($this->http, CURLOPT_USERAGENT, $this->user_agent);
curl_setopt($this->http, CURLOPT_VERBOSE, $this->debug_verbose);
$content = curl_exec($this->http);
Expand Down Expand Up @@ -543,4 +545,19 @@ public function create_issue_link_type_detailed($name, $outward_name, $inward_na
return $this->_put('/admin/issueLinkType/'. urlencode($name) .'?'. http_build_query($params));
}

public function get_verify_ssl() {
return $this->verify_ssl;
}

/**
* Use this method to enable or disable the ssl_verifypeer option of curl.
* This is usefull if you use self-signed ssl certificates.
*
* @param bool $verify_ssl
* @return void
*/
public function set_verify_ssl($verify_ssl) {
$this->verify_ssl = $verify_ssl;
}

}

0 comments on commit 893b127

Please sign in to comment.