Android 签名错误:受信任的证书条目不受密码保护 [英] Android signing error: trusted certificate entries are not password-protected
问题描述
得到了一个证书来签署 android 未签名的发行版 apk 文件,所以我使用命令导入了cer:
Got a certificate to sign the android unsigned release apk files, So I imported the cer using command:
keytool -import -alias alias_name -file cer_name.cer -storepass changeit -keystore my_keystore.keystore
但是当使用 android studio 签署应用程序时,它会产生错误:
But when signing the app with android studio it produces error:
Error:Execution failed for task ':packageDebug'.
> com.android.ide.common.signing.KeytoolException: Failed to read key alias_name from store "C:\Users\username\my_keystore.keystore": trusted certificate entries are not password-protected
我的推论是因为密钥没有密码保护所以我再次尝试并使用以下方法设置密钥的密码:
My deductions said that because the keys are not password protected so i tried again and set the password for keys using:
keytool -import -alias alias_name -file cer_name.cer -storepass changeit -keypass changeit -keystore my_keystore.keystore
但错误仍然存在.
我也尝试过使用 jarsigner 手动操作:
I also tried with manual procedure with jarsigner:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my_keystore.keystore unsigned-release.apk alias_name
出现错误:
jarsigner: Certificate chain not found for: alias_name. alias_name must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.
请帮助我无法获得有关此错误的 Android apk 签名的相关帖子
Please help I am unable to get relevant post on this error for Android apk signings
推荐答案
*.cer 文件通常只包含证书,而不包含签署 APK 所需的私钥.
*.cer files usually only contain certificates, not the private key needed to sign an APK.
列出密钥库的内容:
keytool -list -v -keystore my_keystore.keystore
并寻找 Entry type:
行(对应的别名).该值必须是 PrivateKeyEntry
,而不是 trustedCertEntry
And look for the Entry type:
line (for the corresponding alias). The value must be PrivateKeyEntry
, not trustedCertEntry
这篇关于Android 签名错误:受信任的证书条目不受密码保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!