Skip to content

Commit 9fd4678

Browse files
committed
Add support for custom CA's
1 parent 7d2bd74 commit 9fd4678

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ Mutual TLS authentication serves as a robust method for this purpose. Contrary t
299299
mutual TLS requires both the webhook endpoint (acting as the client) and the webhook provider (acting as the server) to authenticate each other.
300300
This is achieved through an exchange of certificates during the TLS handshake, ensuring that both parties confirm each other's identity.
301301

302+
> Note: If you need to include your own certificate authority, pass the certificate path to the `verifySsl()` method.
303+
302304
```php
303305
WebhookCall::create()
304306
->mutualTls(

src/CallWebhookJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CallWebhookJob implements ShouldQueue
4747

4848
public array $headers = [];
4949

50-
public bool $verifySsl;
50+
public string|bool $verifySsl;
5151

5252
public bool $throwExceptionOnFailure;
5353

src/WebhookCall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function withHeaders(array $headers): self
170170
return $this;
171171
}
172172

173-
public function verifySsl(bool $verifySsl = true): self
173+
public function verifySsl(bool|string $verifySsl = true): self
174174
{
175175
$this->callWebhookJob->verifySsl = $verifySsl;
176176

tests/CallWebhookJobTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,25 @@ function baseGetRequest(array $overrides = []): array
218218
->assertRequestsMade([$baseRequest]);
219219
});
220220

221+
it('will use mutual TLS with certificate authority', function () {
222+
baseWebhook()
223+
->mutualTls('foobar', 'barfoo')
224+
->verifySsl('foofoo')
225+
->dispatch();
226+
227+
$baseRequest = baseRequest();
228+
229+
$baseRequest['options']['cert'] = ['foobar', null];
230+
$baseRequest['options']['ssl_key'] = ['barfoo', null];
231+
$baseRequest['options']['verify'] = 'foofoo';
232+
233+
artisan('queue:work --once');
234+
235+
$this
236+
->testClient
237+
->assertRequestsMade([$baseRequest]);
238+
});
239+
221240
it('will use a proxy', function () {
222241
baseWebhook()
223242
->useProxy('https://proxy.test')

0 commit comments

Comments
 (0)