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

error keystore on initTerminal (java.security.ProviderException: Failed to generate key pair) #486

Open
spnuac opened this issue Aug 30, 2024 · 3 comments

Comments

@spnuac
Copy link

spnuac commented Aug 30, 2024

hello My program works correctly on most devices and there is no problem, but we recently received a POS (KIOSK) register from China, which then crashes during initTerminal and adb gives the following error. Please guide...

Summary

08-30 08:24:40.161 415 19376 E keymaster_worker: HIDL call failed with Status(EX_TRANSACTION_FAILED): 'DEAD_OBJECT: ' @ system/security/keystore/keymaster_worker.cpp:795:auto keystore::KeymasterWorker::generateKey(LockedKeyBlobEntry, hidl_vecandroid::hardware::keymaster::V4_0::KeyParameter, hidl_vec<uint8_t>, int, keystore::KeymasterWorker::generateKey_cb)::(anonymous class)::operator()()
08-30 08:24:40.162 17419 17518 E KeyStore: generateKeyInternal failed on response -1000
08-30 08:24:40.167 17419 17518 E StripeTerminal: class=Terminal
08-30 08:24:40.167 17419 17518 E StripeTerminal: java.security.ProviderException: Failed to generate key pair
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeystoreKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:515)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:471)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at java.security.KeyPairGenerator$Delegate.generateKeyPair(KeyPairGenerator.java:727)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at java.security.KeyPairGenerator.genKeyPair(KeyPairGenerator.java:497)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.stripe.cots.common.compatibility.PreFlightChecks.initialize(PreFlightChecks.kt:70)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.stripe.cots.common.CotsClient.initializeKeys(CotsClient.kt:124)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.initKeystore(CotsAdapter.kt:178)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:1047)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:975)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.stripe.stripeterminal.Terminal.initTerminal(Unknown Source:2)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at io.event1.capacitorstripeterminal.StripeTerminal._initialize(StripeTerminal.java:176)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at io.event1.capacitorstripeterminal.StripeTerminal.initialize(StripeTerminal.java:143)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at java.lang.reflect.Method.invoke(Native Method)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:780)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.os.Handler.handleCallback(Handler.java:938)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.os.Handler.dispatchMessage(Handler.java:99)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.os.Looper.loop(Looper.java:223)
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.os.HandlerThread.run(HandlerThread.java:67)
08-30 08:24:40.167 17419 17518 E StripeTerminal: Caused by: android.security.KeyStoreException: Unknown error
08-30 08:24:40.167 17419 17518 E StripeTerminal: at android.security.KeyStore.getKeyStoreException(KeyStore.java:1301)
08-30 08:24:40.167 17419 17518 E StripeTerminal: ... 21 more
08-30 08:24:40.190 17419 17518 E AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
08-30 08:24:40.190 17419 17518 E AndroidRuntime: Process: com.kiosk.grub24, PID: 17419
08-30 08:24:40.190 17419 17518 E AndroidRuntime: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:789)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:938)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:780)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: ... 6 more
08-30 08:24:40.190 17419 17518 E AndroidRuntime: Caused by: java.security.ProviderException: Failed to generate key pair
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeystoreKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:515)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:471)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at java.security.KeyPairGenerator$Delegate.generateKeyPair(KeyPairGenerator.java:727)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at java.security.KeyPairGenerator.genKeyPair(KeyPairGenerator.java:497)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.stripe.cots.common.compatibility.PreFlightChecks.initialize(PreFlightChecks.kt:70)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.stripe.cots.common.CotsClient.initializeKeys(CotsClient.kt:124)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.stripe.stripeterminal.internal.common.adapter.CotsAdapter.initKeystore(CotsAdapter.kt:178)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:1047)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:975)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at com.stripe.stripeterminal.Terminal.initTerminal(Unknown Source:2)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at io.event1.capacitorstripeterminal.StripeTerminal._initialize(StripeTerminal.java:176)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at io.event1.capacitorstripeterminal.StripeTerminal.initialize(StripeTerminal.java:143)
08-30 08:24:40.190 17419 17518 E AndroidRuntime: ... 9 more
08-30 08:24:40.190 17419 17518 E AndroidRuntime: Caused by: android.security.KeyStoreException: Unknown error
08-30 08:24:40.190 17419 17518 E AndroidRuntime: at android.security.KeyStore.getKeyStoreException(KeyStore.java:1301)

Android version

11

Impacted devices (Android devices or readers)

SDK version

3.8.1

Other information

@ebarrenechea-stripe
Copy link

@spnuac would you be able to provide details about this device (make, model, etc)? Do you have access to another one of those devices that you could try running your app on? We're trying to rule out an issue with this individual device vs an issue for all devices of this particular model.

The error code -1000 from the logs doesn't map to anything useful, unfortunately. One possible issue would be a corrupt keystore. If this is the case then a factory reset should fix the problem.

@harryd31
Copy link

harryd31 commented Oct 1, 2024

@ebarrenechea-stripe Currently experiencing the same issue, seems like it comes from google play services not being on the device. Is there a way around that?

@ebarrenechea-stripe
Copy link

@harryd31 the issue is probably tied to tap to pay as it requires google play services to work properly. We'll look into better handling this error so it doesn't result in a crash when initializing the library. In the mean time, the best approach would be not to include the localmobile artifact in your apk when you need it to run on devices without google play services.

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

3 participants