Skip to content

Commit df061ef

Browse files
committed
Updated the WePay SDK for PHP to force TLS 1.2 connections.
1 parent 5fe79ae commit df061ef

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
WePay PHP SDK
1+
WePay SDK for PHP
22
=============
33

44
WePay's API allows you to easily add payments into your application.
@@ -106,7 +106,32 @@ try {
106106
}
107107
```
108108

109-
And that's it! For more detail on what API calls are available, their parameters and responses, and what permissions they require, please see [our documentation](https://www.wepay.com/developer/reference). For some more detailed examples, look in the `demoapp` directory and check the README. Dropping the entire directory in a web-accessible location and adding your API keys should allow you to be up and running in just a few seconds.
109+
For more details on which API calls are available, their parameters and responses, and which permissions they require,
110+
please see [our documentation](https://www.wepay.com/developer/reference). For some more detailed examples, look in the
111+
`demoapp` directory and check the README. Dropping the entire directory in a web-accessible location and adding your
112+
API keys should allow you to be up and running in just a few seconds.
113+
114+
Security
115+
--------
116+
117+
### Connections require TLS 1.2 ###
118+
119+
According to updated PCI requirements, SSL (v2, v3) and early TLS (1.0, 1.1) are no longer considered “strong
120+
cryptography” and cannot be used as a security control after 2016-06-30. Because of this, WePay will be updating its API
121+
endpoints to only allow TLS 1.2 connections over the coming months.
122+
123+
WePay SDK for PHP version 0.3.0 is _possibly_ backwards-incompatible depending on how new or old your PHP stack is,
124+
hence the [Semantic Versioning](http://semver.org) bump.
125+
126+
Using the [PHP cURL extension](https://secure.php.net/manual/en/intro.curl.php), PHP will make outbound requests via the
127+
system’s cURL installation. For licensing reasons, the PHP cURL extension uses NSS instead of OpenSSL.
128+
129+
* [PHP (Zend Engine) 5.5.19+ or 5.6.3+ is required](https://secure.php.net/manual/en/curl.constants.php).
130+
* The PHP cURL extension requires cURL `7.34.0` (or newer) on the underlying system.
131+
* The PHP cURL extension must be compiled with NSS `3.15.1` (or newer).
132+
* HHVM 3.0 (or newer) and/or Hacklang (any version) has [the same cURL and cURL extension requirements as for
133+
PHP](https://twitter.com/SaraMG/status/631654826426798081).
134+
110135

111136
### SSL Certificate ###
112137

wepay.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class WePay
2626
/**
2727
* Version number - sent in user agent string
2828
*/
29-
const VERSION = '0.2.6';
29+
const VERSION = '0.3.0';
3030

3131
/**
3232
* Scope fields
@@ -102,10 +102,13 @@ public static function getAllScopes()
102102
* Generate URI used during oAuth authorization
103103
* Redirect your user to this URI where they can grant your application
104104
* permission to make API calls
105+
*
105106
* @link https://www.wepay.com/developer/reference/oauth2
106-
* @param array $scope List of scope fields for which your application wants access
107-
* @param string $redirect_uri Where user goes after logging in at WePay (domain must match application settings)
108-
* @param array $options optional user_name,user_email which will be pre-filled on login form, state to be returned in querystring of redirect_uri
107+
*
108+
* @param array $scope List of scope fields for which your application wants access.
109+
* @param string $redirect_uri Where user goes after logging in at WePay (domain must match application settings).
110+
* @param array $options `user_name,user_email` which will be pre-filled on login form, state to be returned
111+
* in query string of redirect_uri. The default value is an empty array.
109112
* @return string URI to which you must redirect your user to grant access to your application
110113
*/
111114
public static function getAuthorizationUri(array $scope, $redirect_uri, array $options = array())
@@ -267,6 +270,11 @@ private static function make_request($endpoint, $values, $headers = array())
267270
curl_setopt(self::$ch, CURLOPT_TIMEOUT, 30); // 30-second timeout, adjust to taste
268271
curl_setopt(self::$ch, CURLOPT_POST, !empty($values)); // WePay's API is not strictly RESTful, so all requests are sent as POST unless there are no request values
269272

273+
// Force TLS 1.2 connections
274+
curl_setopt(self::$ch, CURLOPT_SSL_VERIFYPEER, true);
275+
curl_setopt(self::$ch, CURLOPT_SSL_VERIFYHOST, 2);
276+
curl_setopt(self::$ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
277+
270278
$uri = self::getDomain() . $endpoint;
271279
curl_setopt(self::$ch, CURLOPT_URL, $uri);
272280

@@ -282,8 +290,10 @@ private static function make_request($endpoint, $values, $headers = array())
282290
}
283291
throw new Exception('cURL error while making API call to WePay: cURL Errno - ' . $errno . ', ' . curl_error(self::$ch), $errno);
284292
}
293+
285294
$result = json_decode($raw);
286295
$httpCode = curl_getinfo(self::$ch, CURLINFO_HTTP_CODE);
296+
287297
if ($httpCode >= 400) {
288298
if (!isset($result->error_code)) {
289299
throw new WePayServerException("WePay returned an error response with no error_code, please alert api@wepay.com. Original message: $result->error_description", $httpCode, $result, 0);

0 commit comments

Comments
 (0)