Skip to content

Commit

Permalink
Merge pull request #295 from oshmyheliuk/CEXT-3914
Browse files Browse the repository at this point in the history
CEXT-3914: Add a webhook option to skip certificate validation
  • Loading branch information
keharper authored Dec 18, 2024
2 parents 3c5d324 + be9f328 commit 224d356
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/pages/webhooks/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,49 @@ Responses for a webhook endpoint may be cached if the `ttl` attribute for a hook
```bash
bin/magento cache:clean webhooks_response
```

## Testing webhook endpoint with self-signed SSL certificate

<InlineAlert variant="info" slots="text1" />

SSL verification should be not be disabled in production environments. These options are recommended for development purposes only.

If your webhook endpoint uses a self-signed SSL certificate, you can disable SSL verification for the webhook endpoint by setting the `sslVerification` attribute to `false` in the `hook` element.

```xml
<method name="observer.checkout_cart_product_add_before" type="before">
<hooks>
<batch>
<hook name="validate_stock"
url="{env:APP_BUILDER_PROJECT_URL}/product-validate-stock"
sslVerification="false"
>
<fields>
<field name='product.name' source='data.product.name' />
<field name='product.sku' source='data.product.sku' />
</fields>
</hook>
</batch>
</hooks>
</method>
```

Or, to specify the path to the SSL certificate:

```xml
<method name="observer.checkout_cart_product_add_before" type="before">
<hooks>
<batch>
<hook name="validate_stock"
url="{env:APP_BUILDER_PROJECT_URL}/product-validate-stock"
sslCertificatePath="/path/to/ssl/certificate.pem"
>
<fields>
<field name='product.name' source='data.product.name' />
<field name='product.sku' source='data.product.sku' />
</fields>
</hook>
</batch>
</hooks>
</method>
```
2 changes: 2 additions & 0 deletions src/pages/webhooks/xml-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ The `hook` element defines the HTTP request to the remote server.
| `fallbackErrorMessage` | Int | The error message to return when the hook fails. | false | Not applicable |
| `remove` | Boolean | Indicates whether to skip a removed hook during the batch execution. | false | false |
| `ttl` | Int | The cache time-to-live (in seconds) for requests with the same URL, body, and headers. If this attribute is not specified, or if the value set to `0`, the response is not cached. | false | 0 |
| `sslVerification` | Boolean | Specifies whether SSL certificate verification would be performed during request. Enabled by default. This option should only be used for development purposes. | false | true |
| `sslCertificatePath` | String | Specifies the path to a custom SSL certificate file to use for SSL verification. This option will be ignored if `sslVerification` is set to false. | false | Not applicable |
| `headers` | Array | A set of HTTP headers to send with the request. | false | [] |
| `fields` | Array | A set of fields to include in the hook payload. If not set, the entire payload will be sent. | false | [] |

Expand Down

0 comments on commit 224d356

Please sign in to comment.