Skip to content

Commit

Permalink
Merge pull request #210 from rmccue/default-certificate-path
Browse files Browse the repository at this point in the history
Store default certificate path
  • Loading branch information
rmccue committed May 13, 2016
2 parents a71ab70 + fda0468 commit 8b6a253
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion library/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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) {
Expand All @@ -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
*
Expand Down

0 comments on commit 8b6a253

Please sign in to comment.