|
6 | 6 | * A Twitter library in PHP. |
7 | 7 | * |
8 | 8 | * @package codebird |
9 | | - * @version 2.4.1-dev |
| 9 | + * @version 2.4.1 |
10 | 10 | * @author J.M. <me@mynetx.net> |
11 | 11 | * @copyright 2010-2013 J.M. <me@mynetx.net> |
12 | 12 | * |
@@ -107,7 +107,7 @@ class Codebird |
107 | 107 | /** |
108 | 108 | * The current Codebird version |
109 | 109 | */ |
110 | | - protected $_version = '2.4.1-dev'; |
| 110 | + protected $_version = '2.4.1'; |
111 | 111 |
|
112 | 112 | /** |
113 | 113 | * Returns singleton class instance |
@@ -363,13 +363,32 @@ public function oauth2_token() |
363 | 363 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
364 | 364 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
365 | 365 | 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 | + |
368 | 370 | curl_setopt($ch, CURLOPT_USERPWD, self::$_oauth_consumer_key . ':' . self::$_oauth_consumer_secret); |
369 | 371 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
370 | 372 | 'Expect:' |
371 | 373 | )); |
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 | + |
373 | 392 | $httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
374 | 393 | $reply = $this->_parseApiReply('oauth2/token', $reply); |
375 | 394 | switch ($this->_return_format) { |
|
0 commit comments