gpt4 book ai didi

java - 安卓.security.KeyStoreException : User authentication required after upgrade to android 8

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:21:14 24 4
gpt4 key购买 nike

在 android 8 上更新后,当我尝试创建新 key 以便在指纹身份验证后使用它时,我收到 android.security.KeyStoreException: User authentication required 。在更新到 8 之前,它按预期工作。这并非在所有设备上都会发生。

  mKeyStore.load(null);

KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(
alias,
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT | KeyProperties.PURPOSE_SIGN | KeyProperties.PURPOSE_VERIFY)
.setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA512)
.setSignaturePaddings(KeyProperties.SIGNATURE_PADDING_RSA_PKCS1)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)
.setBlockModes(KeyProperties.BLOCK_MODE_ECB)
.setUserAuthenticationRequired(userAuthenticationRequired)
.setKeyValidityEnd(calendar.getTime())
.setKeySize(keysize)
.build();
mKeyPairGenerator.initialize(spec);
KeyPair keyPair = mKeyPairGenerator.generateKeyPair();//this is the line I'm getting the keystore exception

最佳答案

我们将此问题缩小到 S9 Android 8 设备未使用 PIN、图案或密码进行保护。

一个解决方案是在 generateKeyPair 周围的 try catch block 中添加一个 ProviderException 并在那里处理它。

或者,您可以使用 KeyguardManager.isKeyguardSecure() 来防止 key 生成。

关于java - 安卓.security.KeyStoreException : User authentication required after upgrade to android 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50050247/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com