Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2e63df

Browse files
committed
Merge branch 'release/2.4.1'
2 parents 0e10d93 + c2cbec5 commit d2e63df

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

CHANGELOG

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
codebird-php - changelog
22
========================
33

4-
2.4.1 (not yet released)
4+
2.4.1 (2013-06-23)
55
+ #26 Stringify null and boolean parameters
6+
+ Validate Twitter SSL certificate for oauth2/token method
67

78
2.4.0 (2013-06-15)
89
+ Add contributing guidelines

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Which branch?
2-
- Bugs are fixed in the latest QA_* branch, please base your bugfix pull requests on this branch.
3-
- New features are added to the master branch, please base your feature-add pull requests on that branch.
2+
- Bugs are fixed in the master branch, please base your bugfix pull requests on this branch.
3+
- New features are added to the develop branch, please base your feature-add pull requests on that branch.
44

55
### Code style
66
- Please use 4 soft spaces per indent level.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mynetx/codebird-php",
33
"description" : "A Twitter library in PHP.",
4-
"version": "2.4.1-dev",
4+
"version": "2.4.1",
55
"autoload": {
66
"classmap": ["src/"]
77
},

src/codebird.php

+24-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* A Twitter library in PHP.
77
*
88
* @package codebird
9-
* @version 2.4.1-dev
9+
* @version 2.4.1
1010
* @author J.M. <[email protected]>
1111
* @copyright 2010-2013 J.M. <[email protected]>
1212
*
@@ -107,7 +107,7 @@ class Codebird
107107
/**
108108
* The current Codebird version
109109
*/
110-
protected $_version = '2.4.1-dev';
110+
protected $_version = '2.4.1';
111111

112112
/**
113113
* Returns singleton class instance
@@ -363,13 +363,32 @@ public function oauth2_token()
363363
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
364364
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
365365
curl_setopt($ch, CURLOPT_HEADER, 1);
366-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
367-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
366+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
367+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
368+
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . '/cacert.pem');
369+
368370
curl_setopt($ch, CURLOPT_USERPWD, self::$_oauth_consumer_key . ':' . self::$_oauth_consumer_secret);
369371
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
370372
'Expect:'
371373
));
372-
$reply = curl_exec($ch);
374+
$reply = curl_exec($ch);
375+
376+
// certificate validation results
377+
$validation_result = curl_errno($ch);
378+
if (in_array(
379+
$validation_result,
380+
array(
381+
CURLE_SSL_CERTPROBLEM,
382+
CURLE_SSL_CACERT,
383+
CURLE_SSL_CACERT_BADFILE,
384+
CURLE_SSL_CRL_BADFILE,
385+
CURLE_SSL_ISSUER_ERROR
386+
)
387+
)
388+
) {
389+
throw new \Exception('Error ' . $validation_result . ' while validating the Twitter API certificate.');
390+
}
391+
373392
$httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
374393
$reply = $this->_parseApiReply('oauth2/token', $reply);
375394
switch ($this->_return_format) {

0 commit comments

Comments
 (0)