Skip to content

Commit

Permalink
Merge pull request #79 from voodoodrul/patch-1
Browse files Browse the repository at this point in the history
Allow disabling of CURLOPT_SSL_VERIFYHOST
  • Loading branch information
Ahmad Nassri committed Jun 8, 2015
2 parents 3e37551 + f257217 commit 99c6975
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Unirest/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Request
private static $jsonOpts = array();
private static $socketTimeout = null;
private static $verifyPeer = true;
private static $verifyHost = true;

private static $auth = array (
'user' => '',
Expand Down Expand Up @@ -55,6 +56,16 @@ public static function verifyPeer($enabled)
{
return self::$verifyPeer = $enabled;
}

/**
* Verify SSL host
*
* @param bool $enabled enable SSL host verification, by default is true
*/
public static function verifyHost($enabled)
{
return self::$verifyHost = $enabled;
}

/**
* Set a timeout
Expand Down Expand Up @@ -405,6 +416,8 @@ public static function send($method, $url, $body = null, $headers = array(), $us
CURLOPT_HTTPHEADER => self::getFormattedHeaders($headers),
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => self::$verifyPeer,
//CURLOPT_SSL_VERIFYHOST accepts only 0 (false) or 2 (true). Future versions of libcurl will treat values 1 and 2 as equals
CURLOPT_SSL_VERIFYHOST => self::$verifyHost === false ? 0 : 2,
// If an empty string, '', is set, a header containing all supported encoding types is sent
CURLOPT_ENCODING => ''
));
Expand Down

0 comments on commit 99c6975

Please sign in to comment.