From 42edc2b2e3c04b485eb8d78b032afb7fb6202174 Mon Sep 17 00:00:00 2001 From: thefosk Date: Mon, 6 Jan 2014 20:57:02 +0100 Subject: [PATCH] readme --- README.md | 10 ++++++++++ lib/Unirest/Unirest.php | 15 ++++++++++----- test/Unirest.php | 12 ++++++------ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4e5065e..855184b 100644 --- a/README.md +++ b/README.md @@ -146,3 +146,13 @@ You can clear the default headers anytime with: ```php Unirest::clearDefaultHeaders(); ``` + +### SSL validation + +You can esplicitly enable or disable SSL certificate validation + +```php +Unirest::verifiyPeer(false); +``` + +By default is `true`. diff --git a/lib/Unirest/Unirest.php b/lib/Unirest/Unirest.php index 38db49c..855aa5f 100644 --- a/lib/Unirest/Unirest.php +++ b/lib/Unirest/Unirest.php @@ -5,15 +5,20 @@ class Unirest { - /** - * Verify SSL peer - * @var bool - */ - public static $verifyPeer = true; + + private static $verifyPeer = true; private static $socketTimeout = null; private static $defaultHeaders = array(); + /** + * Verify SSL peer + * @param bool $enabled enable SSL verification, by default is true + */ + public static function verifyPeer($enabled) { + Unirest::$verifyPeer = $enabled; + } + /** * Set a timeout * @param integer $seconds timeout value in seconds diff --git a/test/Unirest.php b/test/Unirest.php index ec691b7..08b96e5 100644 --- a/test/Unirest.php +++ b/test/Unirest.php @@ -6,18 +6,18 @@ echo "Running the Unirest-PHP bindings test suite.\n". $ok = @include_once(dirname(__FILE__).'/simpletest/autorun.php'); if (!$ok) { - $ok = @include_once(dirname(__FILE__).'/../vendor/vierbergenlars/simpletest/autorun.php'); + $ok = @include_once(dirname(__FILE__).'/../vendor/vierbergenlars/simpletest/autorun.php'); } if (!$ok) { - echo "MISSING DEPENDENCY: The Unirest-PHP test cases depend on SimpleTest. ". - "Download it at , and either install it ". - "in your PHP include_path or put it in the test/ directory.\n"; - exit(1); + echo "MISSING DEPENDENCY: The Unirest-PHP test cases depend on SimpleTest. ". + "Download it at , and either install it ". + "in your PHP include_path or put it in the test/ directory.\n"; + exit(1); } // Throw an exception on any error function exception_error_handler($errno, $errstr, $errfile, $errline) { - throw new ErrorException($errstr, $errno, 0, $errfile, $errline); + throw new ErrorException($errstr, $errno, 0, $errfile, $errline); } set_error_handler('exception_error_handler');