Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store default certificate path #210

Merged
merged 1 commit into from
May 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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