gpt4 book ai didi

java - Android keystore 已损坏

转载 作者:IT老高 更新时间:2023-10-28 20:30:04 31 4
gpt4 key购买 nike

一段时间未在 Play 商店中更新我的应用程序后,我尝试使用我的 keystore 对我的一个 APK 进行签名,结果发现 keystore 和别名密码不再起作用。我可以使用此要点重置的 keystore 密码:gist.github.com/zach-klippenstein/4631307现在工作正常。这发生在两个不同应用程序的两个不同 keystore 中。

正在运行 keytool -list -keystore mykeystore结果:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

myalias, Dec 23, 2014, PrivateKeyEntry,
Certificate fingerprint (SHA1): 85:8F:69......

我 100% 确定别名密码与 keystore 密码相同,但它似乎不起作用。我尝试在 Android Studio 中使用 jarsigner -keystore mykeystore -storepass mykeystorepassword app-debug.apk myalias 对 APK 进行签名但响应始终是:jarsigner: unable to recover key from keystore .

我尝试使用 keytool -importkeystore -srckeystore mykeystore -destkeystore newkeystore -srcalias myalias 将别名移动到新的 keystore 文件然后它要求我输入新 keystore 的新密码和旧 keystore 的密码(两者都有效),只有在输入别名密码后我才会收到异常:

Enter destination keystore password:  
Re-enter new password:
Enter source keystore password:
Enter key password for <myalias>
keytool error: java.security.UnrecoverableKeyException: Cannot recover key

经过一些谷歌搜索后,我发现对于某些人来说, keystore 在更新到另一个 JDK 版本或 Android Studio 版本后停止工作,所以我想知道我是否也是这种情况。 keystore 是在 2014 年创建的,所以我当时可能在 JDK7 上(我现在是 8 岁)。两个 keystore 神秘地停止工作也很可疑..

这可以通过某种方式解决吗?

编辑:

我尝试了 Jan 的解决方案,得到了以下结果:

keytool -importkeystore -srckeystore mykeystore -destkeystore newkeystore -deststoretype pkcs12给了我同样的异常(exception):keytool error: java.security.UnrecoverableKeyException: Cannot recover key .

运行此命令后:keytool -importkeystore -srckeystore newkeystore -srcstoretype pkcs12 -destkeystore finalkeystore -deststoretype jks我收到此错误:keytool error: java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.

第二次编辑:

我也尝试在 PC 上使用 JDK7 签署 apk,但不成功。

第三次编辑:

我尝试使用 KeyStore Explorer,它可以很好地打开 keystore 文件并显示一个条目(未过期)。当我尝试打开私钥时,我得到了同样的异常。堆栈跟踪:

java.security.UnrecoverableKeyException: Cannot recover key
at sun.security.provider.KeyProtector.recover(KeyProtector.java:328)
at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:146)
at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:56)
at sun.security.provider.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:96)
at sun.security.provider.JavaKeyStore$DualFormatJKS.engineGetKey(JavaKeyStore.java:70)
at java.security.KeyStore.getKey(KeyStore.java:1023)
at net.sf.keystore_explorer.gui.actions.KeyStoreExplorerAction.unlockEntry(KeyStoreExplorerAction.java:154)
at net.sf.keystore_explorer.gui.actions.KeyStoreExplorerAction.getEntryPassword(KeyStoreExplorerAction.java:123)
at net.sf.keystore_explorer.gui.actions.KeyPairPrivateKeyDetailsAction.doAction(KeyPairPrivateKeyDetailsAction.java:69)
at net.sf.keystore_explorer.gui.actions.KeyStoreExplorerAction.actionPerformed(KeyStoreExplorerAction.java:93)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6535)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

最佳答案

试试

keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -deststoretype pkcs12

keytool -importkeystore -srckeystore new.keystore -srcstoretype pkcs12 -destkeystore final.keystore -deststoretype jks

this question 中的建议.

关于java - Android keystore 已损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35598177/

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