SelfLender / react-native-biometrics

React Native module for iOS and Android biometrics
MIT License
661 stars 225 forks source link

Error: Error creating signature #181

Open camboYY opened 2 years ago

camboYY commented 2 years ago

useBiometrics.ts:89 signature error: Error: Error creating signature at Object.promiseMethodWrapper [as createSignature] (NativeModules.js:103) at Object.createSignature (index.js:68) at _callee4$ (VM6 useBiometrics.bundle:237) at tryCatch (runtime.js:63) at Generator.invoke [as _invoke] (runtime.js:293) at Generator.next (runtime.js:118) at tryCatch (runtime.js:63) at invoke (runtime.js:154) at runtime.js:189 at tryCallTwo (core.js:45)

alexfinset commented 2 years ago

@camboYY If you'd be more specific with the reproduction steps. In my case, I'm getting this error on Android when I enter pin instead of touch id.

The Android source code in CreateSignatureCallback.java below throws an exception in catch block.

    @Override
    public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
        super.onAuthenticationSucceeded(result);

        try {
          ...
        } catch (Exception e) {
            promise.reject("Error creating signature: " + e.getMessage(), "Error creating signature");
        }
    }

When I log this error, it says: android.security.KeyStoreException: Key user not authenticated

sandergo90 commented 2 years ago

@jayfunk we also see this problem using version 2.2.0 using the following scenario:

Using the device pin code, you will receive android.security.KeyStoreException: Key user not authenticated. Setting setUserAuthenticationValidityDurationSeconds to a longer duration, fixes the problem that time. But I don't suppose that's the correct solution for this.

Can you check this please?

Thanks!

vighfx commented 2 years ago

@sandergo90 Curious if there was further solution that helped you resolve this? We have the same issue using device credentials, so really curious, thank you!

sandergo90 commented 2 years ago

At the moment the fix from my comment did the trick. But still waiting for an explanation for it or a proper solution.

jayfunk commented 2 years ago

I have been able to recreate this issue but only on Android 31. Anything below 31 seems to work fine with the pin. @sandergo90 What duration did you set setUserAuthenticationValidityDurationSeconds to? I dont know if that is the right solution. I have been looking for options in 31.

jayfunk commented 2 years ago

I found a solution for the authentication error, but I ran into another issue where I was unable to verify the signed content with the new solution. Maybe someone can take a look at the PR #225 and see what I might have done that caused this regression.

Theokalo commented 1 year ago

Hello guys, I am using the latest version 3.0.1 and I'm having the same problem. I cannot create signature by using the pin code of the android phone. It always fails. Do you have any update on this? Any workaround?

deltasloth commented 1 year ago

@Theokalo were you able to resolve the issue?

aniket-holcim commented 1 year ago

Hello guys, I am trying to create signature on Android by entering pin code but it fails. Do anyone have any update on this issue ?

aniket-holcim commented 1 year ago

@jayfunk we also see this problem using version 2.2.0 using the following scenario:

  • Call the createKeys function
  • Call the createSignature function and don't use the fingerprint for example but enter the device pin code instead

Using the device pin code, you will receive android.security.KeyStoreException: Key user not authenticated. Setting setUserAuthenticationValidityDurationSeconds to a longer duration, fixes the problem that time. But I don't suppose that's the correct solution for this.

Can you check this please?

Thanks!

Hi @sandergo90 Can you please let me know where to use 'setUserAuthenticationValidityDurationSeconds', as I need to integrate it in my project

dbs-tuan commented 7 months ago

@jayfunk we also see this problem using version 2.2.0 using the following scenario:

  • Call the createKeys function
  • Call the createSignature function and don't use the fingerprint for example but enter the device pin code instead

Using the device pin code, you will receive android.security.KeyStoreException: Key user not authenticated. Setting setUserAuthenticationValidityDurationSeconds to a longer duration, fixes the problem that time. But I don't suppose that's the correct solution for this. Can you check this please? Thanks!

Hi @sandergo90 Can you please let me know where to use 'setUserAuthenticationValidityDurationSeconds', as I need to integrate it in my project

You can follow this comment https://github.com/SelfLender/react-native-biometrics/issues/253#issuecomment-1686325156