Skip to content

Commit fd5530a

Browse files
authored
Merge pull request #8683 from vector-im/giomfo/fix_custom_gateway_check
Unified Push: Ignore the potential SSL error when the custom gateway is testing
2 parents 1a94114 + ee2fd9f commit fd5530a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

changelog.d/8683.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unified Push: Ignore the potential SSL error when the custom gateway is testing locally

vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ import im.vector.app.core.resources.StringProvider
2626
import im.vector.app.core.utils.getApplicationLabel
2727
import org.matrix.android.sdk.api.Matrix
2828
import org.matrix.android.sdk.api.cache.CacheStrategy
29+
import org.matrix.android.sdk.api.failure.Failure
2930
import org.matrix.android.sdk.api.util.MatrixJsonParser
3031
import org.unifiedpush.android.connector.UnifiedPush
3132
import timber.log.Timber
3233
import java.net.URL
3334
import javax.inject.Inject
35+
import javax.net.ssl.SSLHandshakeException
3436

3537
class UnifiedPushHelper @Inject constructor(
3638
private val context: Context,
@@ -104,7 +106,11 @@ class UnifiedPushHelper @Inject constructor(
104106
// else, unifiedpush, and pushkey is an endpoint
105107
val gateway = stringProvider.getString(R.string.default_push_gateway_http_url)
106108
val parsed = URL(endpoint)
107-
val port = if (parsed.port != -1) { ":${parsed.port}" } else { "" }
109+
val port = if (parsed.port != -1) {
110+
":${parsed.port}"
111+
} else {
112+
""
113+
}
108114
val custom = "${parsed.protocol}://${parsed.host}${port}/_matrix/push/v1/notify"
109115
Timber.i("Testing $custom")
110116
try {
@@ -120,7 +126,13 @@ class UnifiedPushHelper @Inject constructor(
120126
}
121127
}
122128
} catch (e: Throwable) {
123-
Timber.d(e, "Cannot try custom gateway")
129+
Timber.e(e, "Cannot try custom gateway")
130+
if (e is Failure.NetworkConnection && e.ioException is SSLHandshakeException) {
131+
Timber.w(e, "SSLHandshakeException, ignore this error")
132+
unifiedPushStore.storePushGateway(custom)
133+
onDoneRunnable?.run()
134+
return
135+
}
124136
}
125137
unifiedPushStore.storePushGateway(gateway)
126138
onDoneRunnable?.run()

0 commit comments

Comments
 (0)