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

Migrating LegacySecureStorage on Android doesn't work #21688

Open
ssbssb-cmd opened this issue Apr 7, 2024 · 8 comments
Open

Migrating LegacySecureStorage on Android doesn't work #21688

ssbssb-cmd opened this issue Apr 7, 2024 · 8 comments
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@ssbssb-cmd
Copy link

Description

Followed the steps here to migrate entries from Xamarin SecureStorage into MAUI SecureStorage, but it is always returning null

https://learn.microsoft.com/en-us/dotnet/maui/migration/secure-storage?view=net-maui-8.0

Steps to Reproduce

  1. Create new Xamarin App
  2. Add Xamarin.Essentials
  3. Save a token:
                await SecureStorage.SetAsync("oauth_token", "secret-oauth-token-value");
  1. Create a new MAUI app

  2. Copy paste the code from https://learn.microsoft.com/en-us/dotnet/maui/migration/secure-storage?view=net-maui-8.0, creating new classes for AndroidKeyStore, LegacySecureStorage, KeyChain

  3. Try and retrieve the token

        string token = await LegacySecureStorage.GetAsync("oauth_token");

On Android It is returning null

Link to public reproduction project repository

No response

Version with bug

8.0.6 SR1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Not yet

Relevant log output

No response

@ssbssb-cmd ssbssb-cmd added the t/bug Something isn't working label Apr 7, 2024
@sb111111111
Copy link

Hey - has anyone else experienced this? or found any workaround

@ssbssb-cmd
Copy link
Author

Hi all - anyone else facing this? Am blocked with migrating from xamarin to MAUI at the moment and struggling to work out how to investigate this further or fix

@IainS1986
Copy link

Seen a similar thing I think.

One thing that I'm not sure about, the example code for migration in the AndroidKeyStore code has a call to

LegacySecureStorage.RemoveAll();
This will fire in the first 'Get' call to get a single key (the first decrypt).

This seems - odd. Surely its going to clear all saved secure storage keys the moment you try and get 1, so only the first might work? 🤷

@de-preut
Copy link

de-preut commented May 2, 2024

I'm also currently working in the migration of old SecureStorage items to MAUI and see the same incorrect behaviour. I'm not sure if I missed an important step, but I followed the linked documentation and it's still not working.

@de-preut
Copy link

de-preut commented May 2, 2024

@ssbssb-cmd I think I found a solution! Based on a comment here (jfversluis/Plugin.Maui.FormsMigration#1 (comment)) I created a signing key for my debug configuration (I followed https://learn.microsoft.com/en-us/dotnet/maui/android/deployment/publish-cli?view=net-maui-8.0) and signed the Xamarin.Forms based app as well as the MAUI based app with the same keystore...and it worked!

@IainS1986
Copy link

If you're migrating an android app surely you need to be signing it with the same key, otherwise you're not going to be able to upload to the playstore or install and update over the top?

@PureWeen PureWeen added s/needs-info Issue needs more info from the author area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info labels May 7, 2024
@PureWeen PureWeen added this to the Backlog milestone May 7, 2024
@dotnet-policy-service dotnet-policy-service bot added the s/no-recent-activity Issue has had no recent activity label May 13, 2024
@de-preut
Copy link

If you're migrating an android app surely you need to be signing it with the same key, otherwise you're not going to be able to upload to the playstore or install and update over the top?

yeah, that's true. But (at least in my case) we had the issue in an unsigned debug build as a proof-of-concept if the migration is working. Therefore I was just not aware that even this build needs to be signed already

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author s/no-recent-activity Issue has had no recent activity labels May 14, 2024
@ssbssb-cmd
Copy link
Author

@ssbssb-cmd I think I found a solution! Based on a comment here (jfversluis/Plugin.Maui.FormsMigration#1 (comment)) I created a signing key for my debug configuration (I followed https://learn.microsoft.com/en-us/dotnet/maui/android/deployment/publish-cli?view=net-maui-8.0) and signed the Xamarin.Forms based app as well as the MAUI based app with the same keystore...and it worked!

OK great - i will give it a go! Did you have to do it via command line? Or is there someway within Visual Studio Mac to sign the debug package with the prod key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants