Skip to content

Commit 2eabc62

Browse files
author
Andrew Theken
committed
Allow verification path to be configured by clients.
1 parent 2fa88e1 commit 2eabc62

File tree

3 files changed

+76
-60
lines changed

3 files changed

+76
-60
lines changed

composer.lock

Lines changed: 58 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Postmark/PostmarkClientBase.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ abstract class PostmarkClientBase {
2525
*/
2626
public static $BASE_URL = "https://api.postmarkapp.com";
2727

28+
/**
29+
* CERTIFICATE_PATH is NULL by default.
30+
* This can be set to your own certificate chain if your PHP instance is not able to verify the SSL.
31+
*
32+
* Setting this value causes SSL/TLS requests to use this certificate chain for verifying Postmark requests.
33+
*
34+
* See: https://guzzle.readthedocs.org/en/5.3/clients.html#verify
35+
*
36+
* @var string
37+
*/
38+
public static $CERTIFICATE_PATH = NULL;
39+
2840
protected $authorization_token = NULL;
2941
protected $authorization_header = NULL;
3042
protected $version = NULL;
@@ -52,8 +64,7 @@ protected function processRestRequest($method = NULL, $path = NULL, $body = NULL
5264
$client = new \GuzzleHttp\Client(array('defaults' => array(
5365
'exceptions' => false,
5466
'timeout' => $this->timeout,
55-
),
56-
));
67+
)));
5768

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

@@ -83,6 +94,10 @@ protected function processRestRequest($method = NULL, $path = NULL, $body = NULL
8394
}
8495
}
8596

97+
if (PostmarkClientBase::$CERTIFICATE_PATH != NULL) {
98+
$options['verify'] = PostmarkClientBase::$CERTIFICATE_PATH;
99+
}
100+
86101
$request = $client->createRequest($method, $url, $options);
87102

88103
$v = $this->version;

tests/PostmarkClientBaseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class PostmarkClientBaseTest extends \PHPUnit_Framework_TestCase {
1414
public static function setUpBeforeClass() {
1515
//get the config keys for the various tests
1616
self::$testKeys = new TestingKeys();
17-
PostmarkClientBase::$BASE_URL = self::$testKeys->BASE_URL;
17+
PostmarkClientBase::$BASE_URL = self::$testKeys->BASE_URL ?: 'https://api.postmarkapp.com';
1818
date_default_timezone_set("UTC");
1919
}
2020
}

0 commit comments

Comments
 (0)