aws-amplify / aws-sdk-android

AWS SDK for Android. For more information, see our web site:
https://docs.amplify.aws
Other
1.03k stars 548 forks source link

Error in decryption key initializing CognitoCachingCredentialsProvider #1115

Closed felmoreno1726 closed 5 years ago

felmoreno1726 commented 5 years ago

Describe the bug Amazon crash on initialization of CognitioCachingCredentialsProvider.

To Reproduce A code sample or steps:

//I initialize a Handler class which will handle TextToSpeech requests.
class UtteranceHandler extends Handler {
    //the context passed to handler is MainActivity 
    UtteranceHandler(Context context){
        this.context = new WeakReference<>(context);
        //initialize resources
        initPollyClient();
    }
private void initPollyClient() {
        // Cognito pool ID. Pool needs to be unauthenticated pool with
        // Amazon Polly permissions.
        String COGNITO_POOL_ID = "***";
        // Region of Amazon Polly.
        Regions MY_REGION = ***;
        // Initialize the Amazon Cognito credentials provider.
        CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                context.get(),//program crashes on this line
                COGNITO_POOL_ID,
                MY_REGION
        );
        // Create a client that supports generation of pre-signed URLs.
        client = new AmazonPollyPresigningClient(credentialsProvider);
    }

Which AWS service(s) are affected? I am trying to user the Amazon polly service

Expected behavior A clear and concise description of what you expected to happen. The code shown should initialize a TTS client.

Screenshots This is the application log:

I/AWSKeyValueStore: Detected Android API Level = 28
I/AWSKeyValueStore: Using keyAlias = com.amazonaws.android.auth.aesKeyStoreAlias
D/KeyProvider23: AndroidKeyStore contains keyAlias com.amazonaws.android.auth.aesKeyStoreAlias
    Loading the encryption key from Android KeyStore.
I/AWSKeyValueStore: Creating the AWSKeyValueStore with key for sharedPreferences = com.amazonaws.android.auth
E/: [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
E/AWSKeyValueStore: Error in decrypting data. 
    javax.crypto.AEADBadTagException
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:517)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCachedIdentityId(CognitoCachingCredentialsProvider.java:575)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:429)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43)
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57)
        at android.app.Activity.performCreate(Activity.java:7436)
        at android.app.Activity.performCreate(Activity.java:7426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7470)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
     Caused by: android.security.KeyStoreException: Signature/MAC verification failed
        at android.security.KeyStore.getKeyStoreException(KeyStore.java:851)
        at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224)
        at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:373)
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:506)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.getCachedIdentityId(CognitoCachingCredentialsProvider.java:575) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:429) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43) 
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57) 
        at android.app.Activity.performCreate(Activity.java:7436) 
        at android.app.Activity.performCreate(Activity.java:7426) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:7470) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 
D/CognitoCachingCredentialsProvider: Loading credentials from SharedPreferences
E/AWSKeyValueStore: Error in decrypting data. 
    javax.crypto.AEADBadTagException
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:517)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:588)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43)
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57)
        at android.app.Activity.performCreate(Activity.java:7436)
        at android.app.Activity.performCreate(Activity.java:7426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7470)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
     Caused by: android.security.KeyStoreException: Signature/MAC verification failed
        at android.security.KeyStore.getKeyStoreException(KeyStore.java:851)
        at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224)
        at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:373)
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:506)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:588) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43) 
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57) 
        at android.app.Activity.performCreate(Activity.java:7436) 
        at android.app.Activity.performCreate(Activity.java:7426) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:7470) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 
E/AWSKeyValueStore: Error in decrypting data. 
    javax.crypto.AEADBadTagException
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:517)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:605)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43)
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57)
        at android.app.Activity.performCreate(Activity.java:7436)
        at android.app.Activity.performCreate(Activity.java:7426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7470)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
     Caused by: android.security.KeyStoreException: Signature/MAC verification failed
        at android.security.KeyStore.getKeyStoreException(KeyStore.java:851)
        at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224)
        at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:373)
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:506)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:605) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43) 
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57) 
        at android.app.Activity.performCreate(Activity.java:7436) 
        at android.app.Activity.performCreate(Activity.java:7426) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:7470) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 
E/AWSKeyValueStore: Error in decrypting data. 
    javax.crypto.AEADBadTagException
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:517)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:606)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43)
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57)
        at android.app.Activity.performCreate(Activity.java:7436)
        at android.app.Activity.performCreate(Activity.java:7426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7470)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
     Caused by: android.security.KeyStoreException: Signature/MAC verification failed
        at android.security.KeyStore.getKeyStoreException(KeyStore.java:851)
        at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224)
        at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:373)
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:506)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:606) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43) 
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57) 
        at android.app.Activity.performCreate(Activity.java:7436) 
        at android.app.Activity.performCreate(Activity.java:7426) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:7470) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 
E/AWSKeyValueStore: Error in decrypting data. 
    javax.crypto.AEADBadTagException
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:517)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360)
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:607)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117)
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43)
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57)
        at android.app.Activity.performCreate(Activity.java:7436)
        at android.app.Activity.performCreate(Activity.java:7426)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7470)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
     Caused by: android.security.KeyStoreException: Signature/MAC verification failed
        at android.security.KeyStore.getKeyStoreException(KeyStore.java:851)
        at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224)
        at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:373)
        at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:506)
        at javax.crypto.Cipher.doFinal(Cipher.java:2055) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt(AWSKeyValueStore.java:360) 
        at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get(AWSKeyValueStore.java:207) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.loadCachedCredentials(CognitoCachingCredentialsProvider.java:607) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.initialize(CognitoCachingCredentialsProvider.java:430) 
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.<init>(CognitoCachingCredentialsProvider.java:190) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.initPollyClient(UtteranceHandler.java:117) 
        at com.felmoreno1726.mobilemigrationapp.UtteranceHandler.<init>(UtteranceHandler.java:43) 
        at com.felmoreno1726.mobilemigrationapp.MainActivity.onCreate(MainActivity.java:57) 
        at android.app.Activity.performCreate(Activity.java:7436) 
        at android.app.Activity.performCreate(Activity.java:7426) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) 
        at android.os.Handler.dispatchMessage(Handler.java:109) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:7470) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) 
D/CognitoCachingCredentialsProvider: No valid credentials found in SharedPreferences

Environment Information (please complete the following information):

Additional context Weirdly enough I have been able to start and use the service when I create the TTS client from within another Handler class, but not when it is main Activity that creates the UtteranceHandler instance.

Thanks

mutablealligator commented 5 years ago

@felmoreno1726 Sorry for the inconvenience caused. This issue mainly occurs when the encryption key used to store data is deleted and the new encryption key generated is not able to delete the encrypted data.

I am actively working on a fix as part of #937. I will post an update when there is a PR for testing and when the release will be out.

felmoreno1726 commented 5 years ago

This issue is only present in of the latest sdk updates? I don't see the bug showing up anymore after downgrading to aws_version 2.12.1

mutablealligator commented 5 years ago

@felmoreno1726 Yes. This issue is present only from 2.12.3 version of the SDK where the credentials stored on the device will be encrypted before storing. The summary of the changes are present here: https://github.com/aws-amplify/aws-sdk-android/blob/master/CHANGELOG.md#release-2123

Downgrading the SDK to 2.12.1 is a potential workaround, however I am working on to fix the bugs related to the crash with improvements to the encrpytion key management mechanism.

palpatim commented 5 years ago

We released a fix for this on 2.15.1. Please let us know if you have any questions or continue to see crashes related to retrieving encrypted data.

christina-immanuel commented 5 years ago

I'm on 2.15.2 and I get the same error.

desokroshan commented 5 years ago

@christina-immanuel Thanks for the feedback. We will investigate and get back to you.

RWOverdijk commented 5 years ago

Same issue here. Any news?

mutablealligator commented 5 years ago

@RWOverdijk What version of the SDK are you using? We released a fix for this on 2.15.1. Please let us know if you have any questions or continue to see crashes related to retrieving encrypted data after upgrading to the latest.

RWOverdijk commented 5 years ago

Disabling backups worked so I didn't check again.

mutablealligator commented 5 years ago

Closing the issue as 2.15.1 contains the fix.

Crisp3333 commented 4 years ago

I beg for this issue to be opened up back. It happened has happened twice. And I am using the latest version of the sdk. It happened on Sunday and disappeared Monday, and now it has happened again. This behavior happens when you uninstall your app and try to reinstall it.

mutablealligator commented 4 years ago

@Crisp3333 What version of the SDK are you using? Can you please upgrade to the latest: 2.16.3? We fixed this issue in 2.15.1.

Also if you notice any issues after upgrading to 2.16.3, please post the complete the stacktrace and a code snippet and contents of your build.gradle, the Android API level, device specific details where the issue occurs.

Crisp3333 commented 4 years ago

@kvasukib sorry for the late reply, my app is using 2.15.1. I have fixed the issue today. What I did was go to my app settings in android App Info -> Storage -> Clear data. I think after deleting the app, various data for the app are still on the device, and when you download it again it is using/refering that same stale data/credentials which I believe cause Missing required parameter REFRESH_TOKEN.

mutablealligator commented 4 years ago

@Crisp3333 Thank you for confirming. I am aware of the Missing required parameter REFRESH_TOKEN. issue and 2.15.1 contains the fix for it as well. I recommend clearing the app data, however the SDK has exception handling implemented for errors coming from the persistent store and you shouldn't be seeing this error starting 2.15.1.

I recommend uninstalling and re-installing the app in the worst case if this persists.

Crisp3333 commented 4 years ago

Thank you, I will definitely do that should this problem pops up again.