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

Support encrypted communication with HA #97

Open
robbiet480 opened this issue Dec 4, 2019 · 4 comments · Fixed by home-assistant/core#31743
Open

Support encrypted communication with HA #97

robbiet480 opened this issue Dec 4, 2019 · 4 comments · Fixed by home-assistant/core#31743
Labels
authentication enhancement New feature or request

Comments

@robbiet480
Copy link
Member

Just for that extra bit of security, we should implement encrypted communication with HA over the webhook like iOS supports.

@robbiet480
Copy link
Member Author

Some notes on this:

  • We need to use an updated and peer reviewed library to do this. @JBassett says he looked at https://github.com/terl/lazysodium-android, one option I suggested. The other option is https://github.com/joshjdevl/libsodium-jni. Sadly, both are Java. The only Kotlin option hasn't been updated in 2+ years.
  • Initial support has been added to HA Core to enable encryption on existing registrations (at Add new webhook action to allow enabling encryption in an existing registration core#31743). Call webhook action enable_encryption on HA Core 0.106+, receive a JSON body with secret as the response. HA version can be derived via get_config webhook action. The logic in app should look like this (psuedocode):
    if app_has_no_encryption_key and ha_version > 0.106:
        attempt_to_enable_encryption()
    
  • If enabling encryption fails due to older HA version, then we should either keep doing that check every so often (whenever app starts?) or have a button in settings to allow users to manually enable encryption.

@balloob
Copy link
Member

balloob commented Feb 12, 2020

Do we know the HA version that we talk to ? Seems like something we should know in the app to be able to enable/disable functionality.

@robbiet480
Copy link
Member Author

@balloob We can get that info from the get_config webhook action.

@JBassett
Copy link
Collaborator

JBassett commented Feb 22, 2020

Initial work https://github.com/home-assistant/home-assistant-android/tree/feature/webhookEncryption

I am running into issues with HA decrypting my requests... If anyone wants to take a crack at it please do! I have the sodium library pulled and the ability to easily encrypt/decrypt done. But I must be doing something incorrectly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication enhancement New feature or request
Projects
None yet
3 participants