Skip to content

Commit

Permalink
updating the well known lookup to take into account certificate error…
Browse files Browse the repository at this point in the history
…s when triggered via the sign in with matrix id flow
  • Loading branch information
ouchadam committed May 6, 2022
1 parent 3c9b5d2 commit cf00e00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand All @@ -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()
.newBuilder()
.addSocketFactory(homeServerConnectionConfig)
.build()
} else {
okHttpClient.get()
}
private fun buildClient(homeServerConnectionConfig: HomeServerConnectionConfig): OkHttpClient {
return okHttpClient.get()
.newBuilder()
.addSocketFactory(homeServerConnectionConfig)
.build()
}

/**
Expand Down

0 comments on commit cf00e00

Please sign in to comment.