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

android.security.keystore.UserNotAuthenticatedException: User not authenticated #107

Open
qliqdev opened this issue Jan 16, 2024 · 1 comment

Comments

@qliqdev
Copy link

qliqdev commented Jan 16, 2024

Hello!

setCredentials Method throws exception

android.security.keystore.UserNotAuthenticatedException: User not authenticated
    at android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:128)
    at android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:154)
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:339)
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:234)
    at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2981)
    at javax.crypto.Cipher.tryCombinations(Cipher.java:2892)
    at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2797)
    at javax.crypto.Cipher.chooseProvider(Cipher.java:774)
    at javax.crypto.Cipher.init(Cipher.java:1289)
    at javax.crypto.Cipher.init(Cipher.java:1224)
    at com.epicshaggy.biometric.NativeBiometric.encryptString(NativeBiometric.java:268)
    at com.epicshaggy.biometric.NativeBiometric.setCredentials(NativeBiometric.java:181)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
    at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:780)
    at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)
    at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:211)
    at android.os.Looper.loop(Looper.java:300)
    at android.os.HandlerThread.run(HandlerThread.java:67)

at

try {
                SharedPreferences.Editor editor = getContext().getSharedPreferences(NATIVE_BIOMETRIC_SHARED_PREFERENCES, Context.MODE_PRIVATE).edit();
                editor.putString(KEY_ALIAS + "-username", encryptString(username, KEY_ALIAS));
                editor.putString(KEY_ALIAS + "-password", encryptString(password, KEY_ALIAS));
                editor.apply();
                call.resolve();
            } catch (GeneralSecurityException | IOException e) {
                call.reject("Failed to save credentials", e);
                e.printStackTrace();
            }
@garridomfg
Copy link

garridomfg commented Nov 30, 2024

Hi! I have the same problem, did you find any solution ?

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

No branches or pull requests

2 participants