Skip to content

Commit

Permalink
Merge pull request #401 from opcodesio/improvement/allow-not-to-verif…
Browse files Browse the repository at this point in the history
…y-certificate-when-proxying

ability to skip server certificate verification
  • Loading branch information
arukompas authored Nov 11, 2024
2 parents 993492f + a98ea0f commit c20cc0a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/log-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
// 'username' => 'username',
// 'password' => 'password',
// ],
// 'verify_server_certificate' => true,
// ],
//
// 'production' => [
Expand All @@ -125,6 +126,7 @@
// 'headers' => [
// 'X-Foo' => 'Bar',
// ],
// 'verify_server_certificate' => true,
// ],
],

Expand Down
2 changes: 2 additions & 0 deletions src/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct(
public ?string $host = null,
public ?array $headers = null,
public ?array $auth = null,
public ?bool $verifyServerCertificate = true,
) {
$this->is_remote = $this->isRemote();
}
Expand All @@ -26,6 +27,7 @@ public static function fromConfig(string|int $identifier, array $config = []): s
$config['host'] ?? null,
$config['headers'] ?? [],
$config['auth'] ?? [],
$config['verify_server_certificate'] ?? true,
);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Http/Middleware/ForwardRequestToHostMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function handle(Request $request, Closure $next)
$proxyRequest = $proxyRequest->withDigestAuth($host->auth['username'], $host->auth['password']);
}

if (! $host->verifyServerCertificate) {
$proxyRequest = $proxyRequest->withoutVerifying();
}

$response = $proxyRequest->send($request->method(), $url);

return response(
Expand Down

0 comments on commit c20cc0a

Please sign in to comment.