Skip to content

Commit 99c6975

Browse files
committed
Merge pull request #79 from voodoodrul/patch-1
Allow disabling of CURLOPT_SSL_VERIFYHOST
2 parents 3e37551 + f257217 commit 99c6975

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Unirest/Request.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Request
1515
private static $jsonOpts = array();
1616
private static $socketTimeout = null;
1717
private static $verifyPeer = true;
18+
private static $verifyHost = true;
1819

1920
private static $auth = array (
2021
'user' => '',
@@ -55,6 +56,16 @@ public static function verifyPeer($enabled)
5556
{
5657
return self::$verifyPeer = $enabled;
5758
}
59+
60+
/**
61+
* Verify SSL host
62+
*
63+
* @param bool $enabled enable SSL host verification, by default is true
64+
*/
65+
public static function verifyHost($enabled)
66+
{
67+
return self::$verifyHost = $enabled;
68+
}
5869

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

0 commit comments

Comments
 (0)