Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm having trouble getting SHA1 certificate with keytool

Tags:

I'm trying to find the SHA1 hash of my signature key store on macos sierra using the following comand:

keytool -exportcert -alias androiddebugkey -keystore $HOME/.android/debug.keystore -list -v -storepass android

The result looks like below:

Alias ​​name: androiddebugkey
Date of creation: Oct 25, 2017
Input Type: PrivateKeyEntry
Length of certificate chain: 1
Certificate [1]:
keytool error: java.util.IllegalFormatConversionException: d != java.lang.String java.util.IllegalFormatConversionException: d != java.lang.String at java.base/java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4331) at java.base/java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2846) at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:2800) at java.base/java.util.Formatter.format(Formatter.java:2581) at java.base/java.util.Formatter.format(Formatter.java:2517) at java.base/java.lang.String.format(String.java:2747) at java.base/sun.security.tools.keytool.Main.withWeak(Main.java:3151) at java.base/sun.security.tools.keytool.Main.printX509Cert(Main.java:3182) at java.base/sun.security.tools.keytool.Main.doPrintEntry(Main.java:1995) at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1212) at java.base/sun.security.tools.keytool.Main.run(Main.java:397) at java.base/sun.security.tools.keytool.Main.main(Main.java:390)

As far as I can see the command is working, it is not a problem with the file nor with password, it seems to me an internal error in java, is it missing some java package? I am using Java SDK 9.0.1

like image 556
Jeilson Araujo Avatar asked Oct 26 '17 15:10

Jeilson Araujo


People also ask

How do I get a SHA-1 certificate?

Generate SHA-1 for Release Mode 1-First add keystore config in your gradle How to add config in gradle. 2-After Adding Config in gradle change build variant. 3-Then Follow Above Procedure you will get SHA-1 for release mode. 4-Check Image.

How do I get SHA-1 key for release?

Click on the Gradle tab on the right hand side of the Android Studio window. UPDATE: (Newer versions) In case you don't find an android folder here, go to :app instead of root, navigate to Tasks>android and you'll find signingReport. Double click on signingReport, this will build and post the SHA1 in the bottom view.

How do I find my keystore Sha?

Open your folder where you store your Keystore file in the terminal. Step 2. Now run this command keytool -list -v -keystore {my-app. keystore} -alias {my-app} you need to replace my-app.

How can I change my SHA-1 certificate fingerprint?

Make sure that you have the SHA fingerprint of your signing certificate. In your Project settings, go to the Your apps card. Select the Firebase Android app to which you want to add a SHA fingerprint. Click Add fingerprint.


1 Answers

I found that the problem comes from latest version of Keytool in JDK8.151 and JDK9. By default keytool use system default language and that seems to do not properly work anymore on some languages (in my case French).

It was enough to force output in english by using the parameter -J-Duser.language=en

So try using this command line instead:

keytool -J-Duser.language=en -exportcert -alias androiddebugkey -keystore $HOME/.android/debug.keystore -list -v -storepass android

See also my answer here: https://stackoverflow.com/a/47181882/5292951

like image 52
gbaccetta Avatar answered Sep 30 '22 06:09

gbaccetta