mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Merge pull request #5965 from vector-im/feature/adm/matrix-id-certificate
Handling SSL/TLS errors during WellKnown lookup
This commit is contained in:
commit
ece48baa9d
3 changed files with 13 additions and 11 deletions
1
changelog.d/5965.sdk
Normal file
1
changelog.d/5965.sdk
Normal file
|
@ -0,0 +1 @@
|
|||
Including SSL/TLS error handing when doing WellKnown lookups without a custom HomeServerConnectionConfig
|
|
@ -382,11 +382,16 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
return getWellknownTask.execute(
|
||||
GetWellknownTask.Params(
|
||||
domain = matrixId.getDomain(),
|
||||
homeServerConnectionConfig = homeServerConnectionConfig
|
||||
homeServerConnectionConfig = homeServerConnectionConfig.orWellKnownDefaults()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun HomeServerConnectionConfig?.orWellKnownDefaults() = this ?: HomeServerConnectionConfig.Builder()
|
||||
// server uri is ignored when doing a wellknown lookup as we use the matrix id domain instead
|
||||
.withHomeServerUri("https://dummy.org")
|
||||
.build()
|
||||
|
||||
override suspend fun directAuthentication(homeServerConnectionConfig: HomeServerConnectionConfig,
|
||||
matrixId: String,
|
||||
password: String,
|
||||
|
|
|
@ -43,7 +43,7 @@ internal interface GetWellknownTask : Task<GetWellknownTask.Params, WellknownRes
|
|||
* the URL will be https://{domain}/.well-known/matrix/client
|
||||
*/
|
||||
val domain: String,
|
||||
val homeServerConnectionConfig: HomeServerConnectionConfig?
|
||||
val homeServerConnectionConfig: HomeServerConnectionConfig
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -61,15 +61,11 @@ internal class DefaultGetWellknownTask @Inject constructor(
|
|||
return findClientConfig(params.domain, client)
|
||||
}
|
||||
|
||||
private fun buildClient(homeServerConnectionConfig: HomeServerConnectionConfig?): OkHttpClient {
|
||||
return if (homeServerConnectionConfig != null) {
|
||||
okHttpClient.get()
|
||||
private fun buildClient(homeServerConnectionConfig: HomeServerConnectionConfig): OkHttpClient {
|
||||
return okHttpClient.get()
|
||||
.newBuilder()
|
||||
.addSocketFactory(homeServerConnectionConfig)
|
||||
.build()
|
||||
} else {
|
||||
okHttpClient.get()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue