From 7c58af735b6434fa890b8251d700bf413c78839a Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Wed, 15 Nov 2023 17:10:44 +0100 Subject: [PATCH 1/2] Unified Push: Ignore the potential SSL error when the custom gateway is testing When the Unified Push is enabled, the application checks the potential custom gateway before applying it. If an SSL error happens, the application may ignore this error and keep using this custom gateway. The actual SSL check will be done server side where this gateway is actually used. --- .../vector/app/core/pushers/UnifiedPushHelper.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt b/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt index 77fed03c8a..07052c7146 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt @@ -26,11 +26,13 @@ import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.getApplicationLabel import org.matrix.android.sdk.api.Matrix import org.matrix.android.sdk.api.cache.CacheStrategy +import org.matrix.android.sdk.api.failure.Failure import org.matrix.android.sdk.api.util.MatrixJsonParser import org.unifiedpush.android.connector.UnifiedPush import timber.log.Timber import java.net.URL import javax.inject.Inject +import javax.net.ssl.SSLHandshakeException class UnifiedPushHelper @Inject constructor( private val context: Context, @@ -104,7 +106,11 @@ class UnifiedPushHelper @Inject constructor( // else, unifiedpush, and pushkey is an endpoint val gateway = stringProvider.getString(R.string.default_push_gateway_http_url) val parsed = URL(endpoint) - val port = if (parsed.port != -1) { ":${parsed.port}" } else { "" } + val port = if (parsed.port != -1) { + ":${parsed.port}" + } else { + "" + } val custom = "${parsed.protocol}://${parsed.host}${port}/_matrix/push/v1/notify" Timber.i("Testing $custom") try { @@ -120,7 +126,13 @@ class UnifiedPushHelper @Inject constructor( } } } catch (e: Throwable) { - Timber.d(e, "Cannot try custom gateway") + Timber.e(e, "Cannot try custom gateway") + if (e is Failure.NetworkConnection && e.ioException is SSLHandshakeException) { + Timber.w(e, "SSLHandshakeException, ignore this error") + unifiedPushStore.storePushGateway(custom) + onDoneRunnable?.run() + return + } } unifiedPushStore.storePushGateway(gateway) onDoneRunnable?.run() From ee2fd9f1239790c80978f555ebc6d223968df89c Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Wed, 15 Nov 2023 17:20:37 +0100 Subject: [PATCH 2/2] add changelog --- changelog.d/8683.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8683.bugfix diff --git a/changelog.d/8683.bugfix b/changelog.d/8683.bugfix new file mode 100644 index 0000000000..5ce4bf96b8 --- /dev/null +++ b/changelog.d/8683.bugfix @@ -0,0 +1 @@ +Unified Push: Ignore the potential SSL error when the custom gateway is testing locally