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

Added SSL Validation Override and CA Selection #15

Merged
merged 8 commits into from
Nov 11, 2018
Merged

Added SSL Validation Override and CA Selection #15

merged 8 commits into from
Nov 11, 2018

Conversation

gjabell
Copy link
Contributor

@gjabell gjabell commented Nov 7, 2018

  • Added fields to login page to a) disable ssl validation or b) select
    a custom Certificate Authority certificate to use with the server.

  • Changed visibility of widgets on login page from INVISIBLE to GONE so
    they don't take up space while hidden (since this was causing weird
    spacing issues with the new fields).

  • Added state to settings to store ssl validation choice or certificate
    data.

  • Added fields to various HTTP methods to disable ssl validation or set
    valid certificate authority if either setting is enabled.

- Added fields to login page to a) disable ssl validation or b) select
  a custom Certificate Authority certificate to use with the server.

- Changed visibility of widgets on login page from INVISIBLE to GONE so
  they don't take up space while hidden (since this was causing weird
  spacing issues with the new fields).

- Added state to settings to store ssl validation choice or certificate
  data.

- Added fields to various HTTP methods to disable ssl validation or set
  valid certificate authority if either setting is enabled.
@jmattheis jmattheis self-requested a review November 8, 2018 08:24
Copy link
Member

@jmattheis jmattheis 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 contribution!

The "Disable ssl verification" option works well. The other option for selecting an own certificate I'll test tomorrow (having trouble creating a self-signed certificate with SAN on Windows).

The build (which is currently broken because of #17) would complain about the formatting, could you run gradlew spotlessApply to format all files?

app/src/main/java/com/github/gotify/Utils.java Outdated Show resolved Hide resolved
app/src/main/java/com/github/gotify/Settings.java Outdated Show resolved Hide resolved
app/src/main/java/com/github/gotify/Settings.java Outdated Show resolved Hide resolved
app/src/main/java/com/github/gotify/Utils.java Outdated Show resolved Hide resolved
app/src/main/res/layout/activity_login.xml Outdated Show resolved Hide resolved
- Moved certificate-related utilities to separate class

- Added settings method to return an entire SSLSettings object; refactored
  methods using separate parameters to take single SSLSettings parameter

- Advanced Settings section on login page now hides / shows along with
  other buttons to prevent it from showing up in front of the loading
  spinner

- Fixed star imports

- Refactored applySslSettings as per code from merge request

- Fixed formatting
@gjabell
Copy link
Contributor Author

gjabell commented Nov 9, 2018

I think I covered all the changes request, also formatted using the spotlessApply. Let me know if you find anything else you want changed!

Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

Selecting an certificate works well!

Images from applications currently doesn't load because Picasso doesn't use the certificates see https://stackoverflow.com/a/31860131/4244993

gjabell and others added 4 commits November 10, 2018 10:40
- Removed comment

- Moved SSLSettings to its own top-level class

- Fixed picasso not setting SSL settings and failing to load images over
  self-signed connection
- Switched raw strings to string resources

- Removed unused fields / views from LoginActivity

- Reset 'Check Version' button text when changing SSL settings

- Fixed formatting
@gjabell
Copy link
Contributor Author

gjabell commented Nov 10, 2018

I modified the MessagesActivity class to attempt to set the Picasso singleton instance onCreate with an instance that uses the app's SSL settings and it looks to be working for me. The alternative would be creating a custom holder for a Picasso instance and using that instead of the built-in instance, but that seems a bit messier.

I don't know the lifetime of the Picasso instance (whether it's tied to the lifetime of the activity, or to the app), and since you can't change the singleton once it's been set, there might be an edge-case where someone logs out and logs back in, but uses the same SSL settings from the previous session. Not sure if this is likely enough to matter, though.

Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

I don't know the lifetime of the Picasso instance (whether it's tied to the lifetime of the activity, or to the app), and since you can't change the singleton once it's been set, there might be an edge-case where someone logs out and logs back in, but uses the same SSL settings from the previous session. Not sure if this is likely enough to matter, though.

Good point, yeah this should definitly be fixed. How about creating a single non static instance in MessageActivity#onCreate and passing that to the ListMessageAdapter? (The Context constructor parameter can then be removed from the ListMessageAdapter). Like this a new instance will be created for every MessageActivity and after re-login it should use the new SSLSettings.

The rest looks great! After this fix I'll test it again on my phone and if all is alright then I'll merge this PR (:

@gjabell
Copy link
Contributor Author

gjabell commented Nov 10, 2018

Good idea, I'll go ahead and try that right now. I think the context still needs to be passed though, in order to inflate the view? I can just add another parameter for the picasso instance.

EDIT: Added local instance to MessagesActivity which is passed ListMessageAdapter, seems to work fine for me.

- MessagesActivity now constructs a new Picasso instance each onCreate
  and passes it to ListMessageAdapter
Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

One little change and then all is good!

app/src/main/java/com/github/gotify/api/CertUtils.java Outdated Show resolved Hide resolved
@jmattheis jmattheis merged commit 35970b9 into gotify:master Nov 11, 2018
@jmattheis
Copy link
Member

Thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants