Skip to content

Avoid disabling SSL certificate verification #1

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion lib/FreshBooksRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ public static function init($domain, $token)
{
self::$_domain = $domain;
self::$_token = $token;
self::$_disable_ssl_verification = false;
}

/*
* Turn off SSL peer verification.
*
* You may need to do this if your curl installation does not have
* the proper certificate authority information.
*
* If possible, fix your curl configuration instead as with this
* option set, intermediaries will be able to pretend to be
* FreshBooks.
*
* @return null
*/
public static function disableSSLVerification()
{
self::$_disable_ssl_verification = true;
}

/*
Expand Down Expand Up @@ -163,7 +181,9 @@ public function request()
curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 40s
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // add POST fields
curl_setopt($ch, CURLOPT_USERPWD, self::$_token . ':X');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if (self::$_disable_ssl_verification) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}

$result = curl_exec($ch);

Expand Down