[英]Failed to read key <key> from store ".../keystore.jks": Keystore was tampered with, or password was incorrect
[英]key password from Keystore
我用過這個命令
keytool -genkey -v -keystore ~/nutella.jks -keyalg RSA -keysize 2048 -validity 10000 -alias nutella
生成密鑰庫。 它工作正常,但從我讀過的內容來看,這個命令還應該提示您輸入密鑰密碼(而不是商店密碼)? 我從來沒有得到這個提示。 我可以跑
keytool -v -list -keystore //nutella.jks
查看 Keystore 的內容。 鑰匙似乎在那里......即正確的別名在那里。 我在哪里獲取/設置特定別名的密碼?
我在 android 目錄中有一個 key.properties
storePassword=password
keyPassword=password
keyAlias=ballotbox
storeFile=/Users/gerardhorgan/ballotbox.jks
在 build.gradle 我有:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "app.ballotbox.app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
當我嘗試生成發布版本時,我得到
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release
我認為它可能與 keyPassword 有關,因為我沒有設置它並在可以使用 storePassword 的地方閱讀。
`
試試android
,它是默認的。
可能問題出在錯誤的別名上。
在這段代碼中,您最后提到了 -alias = nutella。
keytool -genkey -v -keystore ~/nutella.jks -keyalg RSA -keysize 2048 -validity 10000 -alias nutella
但是在 key.properties 你有keyAlias=ballotbox
。
只有 Java 9 或更高版本需要 -storetype JKS 標簽。 從 Java 9 版本開始,密鑰庫類型默認為 PKS12。
這意味着,如果您沒有在生成密鑰庫的命令中提供-storetype JKS
,則生成的密鑰庫文件是 PKS12 類型,而不是 JKS。 在 PKS12 格式中,您似乎只能設置存儲密碼,並且在構建期間使用相同的密碼作為密鑰密碼。 因此,當我在 key.properties 文件中為 store 和 key 設置了不同的密碼時,我得到了“given-final-block-not-properly-padded”錯誤,並且當兩者相同時沒有錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.