diff --git a/library/Requests.php b/library/Requests.php index 4ec11cb7d..6a8eef375 100755 --- a/library/Requests.php +++ b/library/Requests.php @@ -106,6 +106,16 @@ class Requests { */ public static $transport = array(); + /** + * Default certificate path. + * + * @see Requests::get_certificate_path() + * @see Requests::set_certificate_path() + * + * @var string + */ + protected static $certificate_path; + /** * This is a static class, do not instantiate it * @@ -506,7 +516,7 @@ protected static function get_default_options($multirequest = false) { 'idn' => true, 'hooks' => null, 'transport' => null, - 'verify' => dirname(__FILE__) . '/Requests/Transport/cacert.pem', + 'verify' => Requests::get_certificate_path(), 'verifyname' => true, ); if ($multirequest !== false) { @@ -515,6 +525,28 @@ protected static function get_default_options($multirequest = false) { return $defaults; } + /** + * Get default certificate path. + * + * @return string Default certificate path. + */ + public static function get_certificate_path() { + if ( ! empty( Requests::$certificate_path ) ) { + return Requests::$certificate_path; + } + + return dirname(__FILE__) . '/Requests/Transport/cacert.pem'; + } + + /** + * Set default certificate path. + * + * @param string $path Certificate path, pointing to a PEM file. + */ + public static function set_certificate_path( $path ) { + Requests::$certificate_path = $path; + } + /** * Set the default values *