Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling SSL/TLS errors during WellKnown lookup #5965

Merged
merged 1 commit into from
May 10, 2022

Conversation

ouchadam
Copy link
Contributor

@ouchadam ouchadam commented May 6, 2022

Type of change

  • Feature
  • Bugfix
  • Technical - SDK
  • Other :

Content

Applies the SSL/TLS certificate handling logic to the sign in with matrix id flow

  • Due to the flow inferring the homeserver url from the matrix id domain it meant we were passing a null HomeserverConnectionConfig which in turn meant the SSL/TLS socket factory was never applied

Motivation and context

To make the sign in with matrix id and other sign in flows consistent

Screenshots / GIFs

Before After
Screenshot_20220506_154304 after-certs

Tests

  • change the device time/date to a month in the past
  • attempt to sign in via sign in with matrix id
  • Notice invalid home server error, however when signing in via other a certificate error is shown

Tested devices

  • Physical
  • Emulator
  • OS version(s): 31

@ouchadam ouchadam added the PR-Small PR with less than 20 updated lines label May 6, 2022
…s when triggered via the sign in with matrix id flow
@ouchadam ouchadam force-pushed the feature/adm/matrix-id-certificate branch from cf00e00 to e97cdb0 Compare May 6, 2022 15:38
@ouchadam ouchadam requested review from a team, onurays and ariskotsomitopoulos and removed request for a team May 6, 2022 15:39
@github-actions
Copy link

github-actions bot commented May 6, 2022

Unit Test Results

122 files  ±0  122 suites  ±0   2m 18s ⏱️ +13s
205 tests ±0  205 ✔️ ±0  0 💤 ±0  0 ±0 
690 runs  ±0  690 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit e97cdb0. ± Comparison against base commit 3c9b5d2.

)
)
}

private fun HomeServerConnectionConfig?.orWellKnownDefaults() = this ?: HomeServerConnectionConfig.Builder()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't too sure about this, I had originally planned to make the service entry point non null but it feels strange to pass the matrix id and a homeserver config (with the url already calculated from the matrix id)

Ideally the getWellKnownData could take the certificate parts of the homeserver config rather than the entire model

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried with non-null parameter in my local but it produces ugly code as so said.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe keep your original plan and add a in the builder something like HomeServerConnectionConfig.Builder.from(matrixId) or withMatrixId(matrixId) to avoid using dummy.org? But it's maybe more confusing :/.
This is not a blocker for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to add a build method and then remove the matrixId from the getWellKnownData 👍

Copy link
Contributor Author

@ouchadam ouchadam May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a go at using the builder for this however the direct usage of Android's Uri breaks the OnboardingViewModel tests
https://github.com/vector-im/element-android/compare/feature/adm/matrix-id-via-builder

there's a bit more refactoring needed to take into account using fake uris

will merge as is for the time being

Copy link
Contributor

@onurays onurays left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ouchadam ouchadam mentioned this pull request May 9, 2022
6 tasks
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!
Just a small can-be-ignored remark.

)
)
}

private fun HomeServerConnectionConfig?.orWellKnownDefaults() = this ?: HomeServerConnectionConfig.Builder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe keep your original plan and add a in the builder something like HomeServerConnectionConfig.Builder.from(matrixId) or withMatrixId(matrixId) to avoid using dummy.org? But it's maybe more confusing :/.
This is not a blocker for me.

@ouchadam ouchadam merged commit ece48ba into develop May 10, 2022
@ouchadam ouchadam deleted the feature/adm/matrix-id-certificate branch May 10, 2022 11:17
@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    = passed=12 failures=3 errors=0 skipped=2
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=25 failures=1 errors=0 skipped=1
  • [org.matrix.android.sdk.ordering]
    = passed=16 failures=0 errors=0 skipped=0
  • [org.matrix.android.sdk.PermalinkParserTest]
    = passed=2 failures=0 errors=0 skipped=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
matrix-sdk PR-Small PR with less than 20 updated lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants