naver / naveridlogin-sdk-android

네이버 아이디로 로그인 SDK (안드로이드)
https://developers.naver.com/docs/login/overview/
Apache License 2.0
114 stars 29 forks source link

[Bug Report] InvalidKeyException: Keystore operation failed #109

Closed minshoki closed 8 months ago

minshoki commented 9 months ago

Bug Report

재현 환경

Android 버전

재현되는 기기 모델명

이슈

이슈 명세

기대한 결과

실제 결과

재현 시나리오

Stack trace

Fatal Exception: java.lang.RuntimeException: Unable to create application {packageName}: java.security.InvalidKeyException: Keystore operation failed
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7593)
       at android.app.ActivityThread.access$1700(ActivityThread.java:315)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2286)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8751)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by java.security.InvalidKeyException: Keystore operation failed
       at android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:130)
       at android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:154)
       at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:345)
       at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:177)
       at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
       at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
       at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
       at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
       at javax.crypto.Cipher.init(Cipher.java:1143)
       at javax.crypto.Cipher.init(Cipher.java:1084)
       at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.encryptInternal(AndroidKeystoreAesGcm.java:85)
       at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.encrypt(AndroidKeystoreAesGcm.java:73)
       at com.google.crypto.tink.integration.android.AndroidKeystoreKmsClient.validateAead(AndroidKeystoreKmsClient.java:298)
       at com.google.crypto.tink.integration.android.AndroidKeystoreKmsClient.getAead(AndroidKeystoreKmsClient.java:180)
       at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readMasterkeyDecryptAndParseKeyset(AndroidKeysetManager.java:365)
       at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:297)
       at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169)
       at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130)
       at com.navercorp.nid.preference.EncryptedPreferences.createSharedPreferences(EncryptedPreferences.kt:59)
       at com.navercorp.nid.preference.EncryptedPreferences.init(EncryptedPreferences.kt:49)
       at com.navercorp.nid.preference.EncryptedPreferences.access$init(EncryptedPreferences.kt:18)
       at com.navercorp.nid.preference.EncryptedPreferences$encryptedPreferences$2.invoke(EncryptedPreferences.kt:31)
       at com.navercorp.nid.preference.EncryptedPreferences$encryptedPreferences$2.invoke(EncryptedPreferences.kt:30)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
       at com.navercorp.nid.preference.EncryptedPreferences.getEncryptedPreferences(EncryptedPreferences.kt:30)
       at com.navercorp.nid.preference.EncryptedPreferences.get(EncryptedPreferences.kt:111)
       at com.navercorp.nid.oauth.NidOAuthPreferencesManager.getClientId(NidOAuthPreferencesManager.kt:54)
       at com.navercorp.nid.preference.EncryptedPreferences.migration(EncryptedPreferences.kt:137)
       at com.navercorp.nid.preference.EncryptedPreferences.setContext(EncryptedPreferences.kt:71)
       at com.navercorp.nid.NaverIdLoginSDK.initialize(NaverIdLoginSDK.kt:86)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7588)
       at android.app.ActivityThread.access$1700(ActivityThread.java:315)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2286)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8751)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by android.security.KeyStoreException: Invalid key blob
       at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:408)
       at android.security.KeyStoreSecurityLevel.createOperation(KeyStoreSecurityLevel.java:122)
       at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:340)
       at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:177)
       at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
       at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
       at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
       at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
       at javax.crypto.Cipher.init(Cipher.java:1143)
       at javax.crypto.Cipher.init(Cipher.java:1084)
       at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.encryptInternal(AndroidKeystoreAesGcm.java:85)
       at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.encrypt(AndroidKeystoreAesGcm.java:73)
       at com.google.crypto.tink.integration.android.AndroidKeystoreKmsClient.validateAead(AndroidKeystoreKmsClient.java:298)
       at com.google.crypto.tink.integration.android.AndroidKeystoreKmsClient.getAead(AndroidKeystoreKmsClient.java:180)
       at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readMasterkeyDecryptAndParseKeyset(AndroidKeysetManager.java:365)
       at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:297)
       at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169)
       at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130)
       at com.navercorp.nid.preference.EncryptedPreferences.createSharedPreferences(EncryptedPreferences.kt:59)
       at com.navercorp.nid.preference.EncryptedPreferences.init(EncryptedPreferences.kt:49)
       at com.navercorp.nid.preference.EncryptedPreferences.access$init(EncryptedPreferences.kt:18)
       at com.navercorp.nid.preference.EncryptedPreferences$encryptedPreferences$2.invoke(EncryptedPreferences.kt:31)
       at com.navercorp.nid.preference.EncryptedPreferences$encryptedPreferences$2.invoke(EncryptedPreferences.kt:30)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
       at com.navercorp.nid.preference.EncryptedPreferences.getEncryptedPreferences(EncryptedPreferences.kt:30)
       at com.navercorp.nid.preference.EncryptedPreferences.get(EncryptedPreferences.kt:111)
       at com.navercorp.nid.oauth.NidOAuthPreferencesManager.getClientId(NidOAuthPreferencesManager.kt:54)
       at com.navercorp.nid.preference.EncryptedPreferences.migration(EncryptedPreferences.kt:137)
       at com.navercorp.nid.preference.EncryptedPreferences.setContext(EncryptedPreferences.kt:71)
       at com.navercorp.nid.NaverIdLoginSDK.initialize(NaverIdLoginSDK.kt:86)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7588)
       at android.app.ActivityThread.access$1700(ActivityThread.java:315)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2286)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8751)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Reference

DayeonLee-0 commented 8 months ago

안녕하세요.

네아로 SDK 담당자입니다.

네아로 SDK v5.9.1에서 InvalidKeyException 대한 예외 처리가 추가되었습니다.

개발에 참고 부탁드립니다.

감사합니다.