keytool : Certificate import gives error message - Keystore was tampered with, or password was incorrect

后端 未结 2 950
小蘑菇
小蘑菇 2020-12-23 15:00

My goal is to generate a certificate, export it in a file and import in JDK keystore.

In first step I have generated a self signed certificate using

2条回答
  •  有刺的猬
    2020-12-23 15:43

    IF you're able to build your app from a PC, but you don't recall the password, here's what you can do to retrieve the password:

    Method 1:

    In your build.gradle, add println MYAPP_RELEASE_KEY_PASSWORD as below:

    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
                println MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    

    After that, run cd android && ./gradlew assembleRelease

    Method 2:

    Run keytool -list -v -keystore your <.keystore file path> e.g. keytool -list -v -keystore ./app/my-app-key.keystore.

    It will ask for you to Enter keystore password: Just press enter key here. and you will be able to find mapped to Alias name:

    Then, run grep -rn "" . in your terminal and you will be able to see your signing.json file as below:

    ./app/build/intermediates/signing_config/release/out/signing-config.json
    

    The file will have your password in json format with key "mKeyPassword":" < your password > "

提交回复
热议问题