Skip to content

Commit

Permalink
Fix bug with curl ssl verify peer
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Aug 29, 2017
1 parent 386b91b commit 818dbdb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Changelog

## master
[v6.0.1...master](https://github.com/deployphp/deployer/compare/v6.0.1...master)
[v6.0.2...master](https://github.com/deployphp/deployer/compare/v6.0.2...master)

🍰

## v6.0.2
[v6.0.1...v6.0.2](https://github.com/deployphp/deployer/compare/v6.0.1...v6.0.2)

### Fixed
- Fixed bug with curl ssh check in _Httpie_ util

## v6.0.1
[v6.0.0...v6.0.1](https://github.com/deployphp/deployer/compare/v6.0.0...v6.0.1)
Expand Down
7 changes: 7 additions & 0 deletions KNOWN_BUGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ ControlPersist causes stderr to be left open until the master connection times o

* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714526
* https://bugzilla.mindrot.org/show_bug.cgi?id=1988


## cURL 7.29.0

Certificate verification fails with multiple https urls.

* https://bugzilla.redhat.com/show_bug.cgi?id=1241172
11 changes: 11 additions & 0 deletions src/Utility/Httpie.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Httpie
private $url = '';
private $headers = [];
private $body = '';
private $curlopts = [];

public function __construct()
{
Expand Down Expand Up @@ -76,6 +77,13 @@ public function form(array $data): Httpie
return $http;
}

public function setopt($key, $value)
{
$http = clone $this;
$http->curlopts[$key] = $value;
return $http;
}

public function send()
{
$ch = curl_init($this->url);
Expand All @@ -87,6 +95,9 @@ public function send()
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
foreach ($this->curlopts as $key => $value) {
curl_setopt($ch, $key, $value);
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
Expand Down
15 changes: 10 additions & 5 deletions src/Utility/Reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class Reporter
{
const ENDPOINT = 'https://deployer.org/api/stats';

/**
* @param array $stats
*/
public static function report(array $stats)
{
$pid = null;
Expand All @@ -28,20 +25,28 @@ public static function report(array $stats)
if (is_null($pid) || $pid === -1) {
// Fork fails or there is no `pcntl` extension.
try {
Httpie::post(self::ENDPOINT)->body($stats)->send();
self::send($stats);
} catch (\Throwable $e) {
// pass
}
} elseif ($pid === 0) {
// Child process.
posix_setsid();
try {
Httpie::post(self::ENDPOINT)->body($stats)->send();
self::send($stats);
} catch (\Throwable $e) {
// pass
}
// Close child process after doing job.
exit(0);
}
}

private static function send(array $stats)
{
Httpie::post(self::ENDPOINT)
->body($stats)
->setopt(CURLOPT_SSL_VERIFYPEER, false)
->send();
}
}

0 comments on commit 818dbdb

Please sign in to comment.