Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(webhooks): use mTLS callback URL only when mtls verification is enabled and required (#15261)
Sayak Bhattacharya4bafece8bbf6
diff --git a/crates/router/src/core/merchant_connector_webhook_management.rs b/crates/router/src/core/merchant_connector_webhook_management.rsindex d1df59eb94..1ddb487804 100644--- a/crates/router/src/core/merchant_connector_webhook_management.rs+++ b/crates/router/src/core/merchant_connector_webhook_management.rs@@ -27,6 +27,7 @@ use transformers as configure_connector_webhook_flow;use crate::{consts,core::{+ configs::dimension_state,errors::{self, ConnectorErrorExt, RouterResponse, StorageErrorExt},payments::helpers,utils as core_utils,@@ -228,8 +229,17 @@ pub async fn register_connector_webhook(.get_webhook_registration_plan(scope, &state.conf.connectors).to_webhook_configuration_failed_response()?;+ let connector_requires_mtls = connector_data.connector.is_webhook_mtls_required();+ let mtls_verification_enabled = dimension_state::Dimensions::new()+ .with_connector(connector_data.connector_name)+ .get_incoming_webhook_mtls_verification_enabled(+ state.store.as_ref(),+ state.superposition_service.as_ref(),+ None,+ )+ .await;let webhook_base_url = state- .get_webhook_registration_base_url(connector_data.connector.is_webhook_mtls_required())?;+ .get_webhook_registration_base_url(connector_requires_mtls, mtls_verification_enabled)?;let scope_type = configure_connector_webhook_flow::determine_scope_type(scope);let requested = configure_connector_webhook_flow::extract_requested_identifiers(scope);diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex db5e31ca94..281f7e7fc8 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -190,12 +190,13 @@ impl SessionState {pub(crate) fn get_webhook_registration_base_url(&self,connector_requires_mtls: bool,+ mtls_verification_enabled: bool,) -> RouterResult<&str> {- if connector_requires_mtls {+ if connector_requires_mtls && mtls_verification_enabled {self.tenant.mtls_base_url.as_deref().ok_or_else(|| {error_stack::Report::new(errors::ApiErrorResponse::InternalServerError).attach_printable(- "mtls_base_url must be configured for connectors that require mTLS webhooks",+ "mtls_base_url must be configured when mTLS webhook verification is required and enabled",)})} else {