From 698c21c8f605803bada55936d726f54346b51f75 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 14 Dec 2023 10:46:00 +0100 Subject: [PATCH 1/2] add Config::disableSSLVerification() --- CHANGELOG.md | 6 ++++++ composer.json | 2 +- src/Config.php | 37 +++++++++++++++++++++++++++++++++++++ src/Remote/Generic.php | 4 ++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a73a1..ce868f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Added + +- `Innmind\OperatingSystem\Config::disableSSLVerification()` + ## 4.1.0 - 2023-11-05 ### Added diff --git a/composer.json b/composer.json index 494e623..5d3dd93 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "innmind/server-control": "~5.0", "innmind/filesystem": "~7.1", "innmind/socket": "~6.0", - "innmind/http-transport": "~7.0", + "innmind/http-transport": "~7.2", "innmind/time-warp": "~3.0", "innmind/signals": "~3.0", "innmind/file-watch": "~3.1", diff --git a/src/Config.php b/src/Config.php index 92ffb53..9aa7adc 100644 --- a/src/Config.php +++ b/src/Config.php @@ -30,6 +30,7 @@ final class Config private Maybe $maxHttpConcurrency; /** @var Maybe */ private Maybe $httpHeartbeat; + private bool $disableSSLVerification; /** * @param Maybe $maxHttpConcurrency @@ -44,6 +45,7 @@ private function __construct( EnvironmentPath $path, Maybe $maxHttpConcurrency, Maybe $httpHeartbeat, + bool $disableSSLVerification, ) { $this->clock = $clock; $this->caseSensitivity = $caseSensitivity; @@ -53,6 +55,7 @@ private function __construct( $this->path = $path; $this->maxHttpConcurrency = $maxHttpConcurrency; $this->httpHeartbeat = $httpHeartbeat; + $this->disableSSLVerification = $disableSSLVerification; } public static function of(): self @@ -74,6 +77,7 @@ public static function of(): self EnvironmentPath::of(\getenv('PATH') ?: ''), $maxHttpConcurrency, $httpHeartbeat, + false, ); } @@ -91,6 +95,7 @@ public function withClock(Clock $clock): self $this->path, $this->maxHttpConcurrency, $this->httpHeartbeat, + $this->disableSSLVerification, ); } @@ -108,6 +113,7 @@ public function caseInsensitiveFilesystem(): self $this->path, $this->maxHttpConcurrency, $this->httpHeartbeat, + $this->disableSSLVerification, ); } @@ -129,6 +135,7 @@ public function useStreamCapabilities(Capabilities $capabilities): self $this->path, $this->maxHttpConcurrency, $this->httpHeartbeat, + $this->disableSSLVerification, ); } @@ -146,6 +153,7 @@ public function haltProcessVia(Halt $halt): self $this->path, $this->maxHttpConcurrency, $this->httpHeartbeat, + $this->disableSSLVerification, ); } @@ -163,6 +171,7 @@ public function withEnvironmentPath(EnvironmentPath $path): self $path, $this->maxHttpConcurrency, $this->httpHeartbeat, + $this->disableSSLVerification, ); } @@ -182,6 +191,7 @@ public function limitHttpConcurrencyTo(int $max): self $this->path, Maybe::just($max), $this->httpHeartbeat, + $this->disableSSLVerification, ); } @@ -201,6 +211,25 @@ public function withHttpHeartbeat(ElapsedPeriod $timeout, callable $heartbeat): $this->path, $this->maxHttpConcurrency, Maybe::just([$timeout, $heartbeat]), + $this->disableSSLVerification, + ); + } + + /** + * @psalm-mutation-free + */ + public function disableSSLVerification(): self + { + return new self( + $this->clock, + $this->caseSensitivity, + $this->streamCapabilities, + $this->io, + $this->halt, + $this->path, + $this->maxHttpConcurrency, + $this->httpHeartbeat, + true, ); } @@ -271,4 +300,12 @@ public function httpHeartbeat(): Maybe { return $this->httpHeartbeat; } + + /** + * @internal + */ + public function mustDisableSSLVerification(): bool + { + return $this->disableSSLVerification; + } } diff --git a/src/Remote/Generic.php b/src/Remote/Generic.php index 9143cb7..841f1eb 100644 --- a/src/Remote/Generic.php +++ b/src/Remote/Generic.php @@ -85,6 +85,10 @@ public function http(): HttpTransport static fn($config) => $http->heartbeat($config[0], $config[1]), static fn() => $http, ); + $http = match ($this->config->mustDisableSSLVerification()) { + true => $http->disableSSLVerification(), + false => $http, + }; return $this->http = $http; } From e25ed951a6078fa3fe357c0437b472d4abeccbda Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 14 Dec 2023 10:53:10 +0100 Subject: [PATCH 2/2] specify next release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce868f5..e678341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased] +## 4.2.0 - 2023-12-14 ### Added