mibrito707 / cordova-plugin-secure-storage-echo

Secure storage plugin for Apache Cordova

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android - Error: KeyStore doesn't contain alias: (com.test.testapp.test_store)

manuchandra962 opened this issue · comments

Mobile Application
Ionic 5 and Angular 9
cordova-plugin-secure-storage-echo - 5.1.1

Device -
Honor 7x - v9
Samsung J5 Prime - v8

Init is failing. Does anyone encounter the same issue?
WhatsApp Image 2020-07-14 at 10 13 44

@manuchandra962 I have the same issue, any progress on that? Did you manage to find a solution yet? Thanks!

@sberube - Bypassing "isInsideSecureHardware" solves issue in few devices. But not sure will it cause any security threat.

I currently have the same problem. I realy need a fix or Workaround for this, as the app should release soon.
@manuchandra962 @mibrito707 anything i can do about this?

I'm experiencing this issue in some cases as well. It appears to occur only the first time a new version of the app is installed.

commented

We have the same issue, following

I'm facing same issue with new package version 5.1.1 Android 10 OS and ionic 5, Cordova android - 9.0. Is it ok to roll back to 5.0.1 version what would be the right solution.

@takhil do you have the issue with 5.0.1?

Actually, we seem to have the issue when multiple versions of the app (signed and unsigned) has been installed on our device.

But, by calling the following code in the app initialization (this.platform.ready().then) it seems to fix the issue 🤷‍♂️. Unfortunately, this workaround is not acceptable for us 😭.

 return SecureStorage.create(this.KEYSTORE).then((store) => { 
            store.clear();
 })

@takhil do you have the issue with 5.0.1?

Actually, we seem to have the issue when multiple versions of the app (signed and unsigned) has been installed on our device.

But, by calling the following code in the app initialization (this.platform.ready().then) it seems to fix the issue 🤷‍♂️. Unfortunately, this workaround is not acceptable for us 😭.

 return SecureStorage.create(this.KEYSTORE).then((store) => { 
            store.clear();
 })

@sberube - I rolled back to version 5.0.1 with out any code changes and working as expected.

I am also experiencing this issue for Ionic 5, Angular 9, plugin ver 5.1.0.
The issue also only happens on a fresh install of the app, if updating from a previous version the store plugin works as expected.

I tried downgrading to 5.0.1 but the issue is still present.

I had the same issue with this plugin v5.1.1 and downgrading to v5.0.1 resolved it.
But I recently upgrade Node.js v8 to v12 and now I have this issue with both version of the plugin.
... Any suggestion ?

I had the same issue with this plugin v5.1.1 and downgrading to v5.0.1 resolved it.
But I recently upgrade Node.js v8 to v12 and now I have this issue with both version of the plugin.
... Any suggestion ?

Can you try to remove all modules and plugins and try ? I'm node v 12.x works fine. Make sure you rollback to below.

"@ionic-native/secure-storage": "5.26.0",
"cordova-plugin-secure-storage-echo": "5.0.1",

I am also experiencing this issue for Ionic 5, Angular 9, plugin ver 5.1.0.
The issue also only happens on a fresh install of the app, if updating from a previous version the store plugin works as expected.

I tried downgrading to 5.0.1 but the issue is still present.

Can you try to remove all modules and plugins and try ? I'm node v 12.x works fine. Make sure you rollback to below.

"@ionic-native/secure-storage": "5.26.0",
"cordova-plugin-secure-storage-echo": "5.0.1",

Can you try to remove all modules and plugins and try ? I'm node v 12.x works fine. Make sure you rollback to below.

Hi ! I just deleted cordova from my project and regenerated it with all plugins for the Android platform... the famous error message disappeared.
I think it is because I write this in config.xml :
<plugin` name="cordova-plugin-secure-storage-echo" spec="^5.0.1"/>, so 5.1.1 been downloaded instead of 5.0.1...

Thank you for your help!

Having this issue as well. Running android 10 with:

 "@ionic-native/secure-storage-echo": "^5.27.0",
 "cordova-plugin-secure-storage-echo": "^5.1.1",

It happens when I uninstall app without clearing app caches. Then after second installation I see blank screen and 'keystore doesn't contain alias XXX' error in logs. I can also see that it actually happens AFTER creating secure storage:

Code:

   platform.ready().then(() => {
            console.log('Platform is ready.');
                this.secureStorage.create('XXXXX')
                    .then((storage: SecureStorageEchoObject) => {
                       this.storage = storage;
                
                       console.log('Secure storage is ready.');
                       // Writing stuff to secure storage here.
                     }).catch(e => {
                        this.handleLockScreenRequired(e);
                  }

Logs:

09-25 14:17:19.826 27605 27605 D SystemWebChromeClient: http://localhost/main-es2015.d38f3407f38c5a4207d4.js: Line 1 : Ionic Native: deviceready event fired after 396 ms
09-25 14:17:19.827 27605 27605 D SystemWebChromeClient: http://localhost/main-es2015.d38f3407f38c5a4207d4.js: Line 1 : Platform is ready.
09-25 14:17:19.846 27605 27605 D SystemWebChromeClient: http://localhost/main-es2015.d38f3407f38c5a4207d4.js: Line 1 : Secure storage is ready.
09-25 14:17:19.861 27605 27605 D SystemWebChromeClient: http://localhost/main-es2015.d38f3407f38c5a4207d4.js: Line 1 : ERROR Error: KeyStore doesn't contain alias: XXXXX

For now I'll try to clear storage when this error occurs and reinitailize storage again.

Here're logs from SecureStorage plugin:

09-25 15:08:10.807  6140  6240 E SecureStorage: java.lang.Exception: KeyStore doesn't contain alias: XXXX
09-25 15:08:10.807  6140  6240 E SecureStorage:         at com.crypho.plugins.AbstractRSA.loadKey(AbstractRSA.java:75)
09-25 15:08:10.807  6140  6240 E SecureStorage:         at com.crypho.plugins.AbstractRSA.runCipher(AbstractRSA.java:44)
09-25 15:08:10.807  6140  6240 E SecureStorage:         at com.crypho.plugins.AbstractRSA.decrypt(AbstractRSA.java:65)
09-25 15:08:10.807  6140  6240 E SecureStorage:         at com.crypho.plugins.SecureStorage$3.run(SecureStorage.java:163)
09-25 15:08:10.807  6140  6240 E SecureStorage:         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
09-25 15:08:10.807  6140  6240 E SecureStorage:         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
09-25 15:08:10.807  6140  6240 E SecureStorage:         at java.lang.Thread.run(Thread.java:919)

Cleaning the app cache and data solved it for me ❤️

Cleaning the app cache and data solved it for me ❤️

Yeah, but tell this to non-technical users of your app ;). But I can confirm - it works after cleaning caches.

Cleaning the app cache and data solved it for me ❤️

Yeah, but tell this to non-technical users of your app ;). But I can confirm - it works after cleaning caches.

For me, I did some changes to the app, like renaming it. perhaps this might be the case?

I manged to fix this issue by clearing storage after exception. Error happens right after getting any value from storage, so in order to fix that I'm fetching storage keys via storage.keys() and then looping for each key trying to get it's value. When exception occurs I'm clearing whole storage by storage.clear().

I manged to fix this issue by clearing storage after exception. Error happens right after getting any value from storage, so in order to fix that I'm fetching storage keys via storage.keys() and then looping for each key trying to get it's value. When exception occurs I'm clearing whole storage by storage.clear().

Can you please post your algorithm or code for doing this? Thanks

Any information/insight from the library developers? None of the above workarounds are working for me. Asking a new user that just installed your app to go and clear storage is crazy.

We're having the same issue, and clearing the storage doesn't seem to fix it. The main test device is a Galaxy A7 running Android 7.0.

It's worth noting that on Cordova Android 6.3.0 you will get prompted for your PIN on every start, and even with the correct PIN the secure storage will fail to load, but with 8.1.0 you get the KeyStore doesn't contain error, which suggests that we're seeing multiple forms of the same issue. Secure Storage used to work on this app, and I've been going through the changes before the issue started manifesting and it looks like the cordova android platform version is the only thing that changed.

We're having the same issue, and clearing the storage doesn't seem to fix it. The main test device is a Galaxy A7 running Android 7.0.

It's worth noting that on Cordova Android 6.3.0 you will get prompted for your PIN on every start, and even with the correct PIN the secure storage will fail to load, but with 8.1.0 you get the KeyStore doesn't contain error, which suggests that we're seeing multiple forms of the same issue. Secure Storage used to work on this app, and I've been going through the changes before the issue started manifesting and it looks like the cordova android platform version is the only thing that changed.

Further update. I did some additional testing and realized that the original issue with 8.1.0 was probably due to a shared key that wasn't correctly removed in the platform when the configuration file was updated. The change in behavior was due to removing and re-adding the android platform instead of changing the cordova-android itself. I've also tried updating to cordova-cli 9 and 10, as well as with android version 9 and the behavior remains the same.

How strange, I have been using this plugin for 10 months and have never had this problem reported. Today I have an app with more than 2 thousand installations diversified on Android 6, 7, 8 and 9 without any problem.

What information can I provide to help you?

Ionic:

   Ionic CLI                     : 6.11.11 (/Users/ludufre/.npm-packages/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.3.4
   @angular-devkit/build-angular : 0.901.12
   @angular-devkit/schematics    : 9.1.12
   @angular/cli                  : 9.1.12
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : 6.0.0, android 9.0.0, browser, ios 6.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 26 other plugins)

Utility:

   cordova-res : 0.15.1
   native-run  : 1.2.1

System:

   Android SDK Tools : 26.1.1 (/Users/ludufre/Library/Android/sdk)
   ios-deploy        : 1.11.2
   ios-sim           : 8.0.2
   NodeJS            : v12.18.1 (/usr/local/bin/node)
   npm               : 6.14.8
   OS                : macOS Big Sur
   Xcode             : Xcode 12.0.1 Build version 12A7300

We have the same issue - if the user does a first install or clears the storage and cache of the app, the aforementioned error appears.

I manually made the change from #61, see: b641676

It seems to work... Maybe others could also try this and report back?

Thanks!
Nicola

adding these to the application tag in the manifest solved it for me:
android:allowBackup="false" android:fullBackupContent="false"

any update on this issue as i am facing the same