summaryrefslogtreecommitdiff
path: root/src/Request.php
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-01-15 13:54:52 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-01-15 13:54:52 +0100
commitfaf9ddfc29676b86621bdc3033e05d63df5c2a93 (patch)
tree353517d8ce5c20ff7476b7d50f3505b37b2c5051 /src/Request.php
parent3776ab80f23c07943d2228f2975e515c494f930a (diff)
client certificate handling and workaroundHEADmain
Diffstat (limited to 'src/Request.php')
-rw-r--r--src/Request.php29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/Request.php b/src/Request.php
index ceb7dbb..82ce0d3 100644
--- a/src/Request.php
+++ b/src/Request.php
@@ -8,8 +8,9 @@ class Request
protected string $host;
protected string $path;
protected array $query;
+ protected ?ClientCertificate $clientCertificate;
- public function __construct(string $url)
+ public function __construct(string $url, ?ClientCertificate $clientCertificate = null)
{
$requestUrl = parse_url($url);
@@ -29,6 +30,8 @@ class Request
}
}
}
+
+ $this->clientCertificate = $clientCertificate;
}
/**
@@ -36,7 +39,17 @@ class Request
*/
public static function fromResource($resource): static
{
- return Request::fromString(fread($resource, 1024));
+ $request = Request::fromString(fread($resource, 1024));
+
+ $clientCertificate = null;
+ $streamParams = stream_context_get_params($resource);
+ $peerCertificate = $streamParams['options']['ssl']['peer_certificate'] ?? null;
+ if ($peerCertificate) {
+ $clientCertificate = new ClientCertificate($peerCertificate);
+ $request->setClientCertificate($clientCertificate);
+ }
+
+ return $request;
}
public static function fromString(string $string): static
@@ -67,4 +80,16 @@ class Request
return $this;
}
+
+ public function getClientCertificate(): ?ClientCertificate
+ {
+ return $this->clientCertificate;
+ }
+
+ public function setClientCertificate(ClientCertificate $clientCertificate): self
+ {
+ $this->clientCertificate = $clientCertificate;
+
+ return $this;
+ }
}