Skip to content

Commit 7c58af7

Browse files
committed
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.
1 parent 1a94114 commit 7c58af7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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)