Skip to content

Commit

Permalink
Allow verification path to be configured by clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Theken committed Sep 21, 2015
1 parent 2fa88e1 commit 2eabc62
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 60 deletions.
115 changes: 58 additions & 57 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions src/Postmark/PostmarkClientBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ abstract class PostmarkClientBase {
*/
public static $BASE_URL = "https://api.postmarkapp.com";

/**
* CERTIFICATE_PATH is NULL by default.
* This can be set to your own certificate chain if your PHP instance is not able to verify the SSL.
*
* Setting this value causes SSL/TLS requests to use this certificate chain for verifying Postmark requests.
*
* See: https://guzzle.readthedocs.org/en/5.3/clients.html#verify
*
* @var string
*/
public static $CERTIFICATE_PATH = NULL;

protected $authorization_token = NULL;
protected $authorization_header = NULL;
protected $version = NULL;
Expand Down Expand Up @@ -52,8 +64,7 @@ protected function processRestRequest($method = NULL, $path = NULL, $body = NULL
$client = new \GuzzleHttp\Client(array('defaults' => array(
'exceptions' => false,
'timeout' => $this->timeout,
),
));
)));

$url = PostmarkClientBase::$BASE_URL . $path;

Expand Down Expand Up @@ -83,6 +94,10 @@ protected function processRestRequest($method = NULL, $path = NULL, $body = NULL
}
}

if (PostmarkClientBase::$CERTIFICATE_PATH != NULL) {
$options['verify'] = PostmarkClientBase::$CERTIFICATE_PATH;
}

$request = $client->createRequest($method, $url, $options);

$v = $this->version;
Expand Down
2 changes: 1 addition & 1 deletion tests/PostmarkClientBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class PostmarkClientBaseTest extends \PHPUnit_Framework_TestCase {
public static function setUpBeforeClass() {
//get the config keys for the various tests
self::$testKeys = new TestingKeys();
PostmarkClientBase::$BASE_URL = self::$testKeys->BASE_URL;
PostmarkClientBase::$BASE_URL = self::$testKeys->BASE_URL ?: 'https://api.postmarkapp.com';
date_default_timezone_set("UTC");
}
}
Expand Down

0 comments on commit 2eabc62

Please sign in to comment.