问题
I'm following Google's tutorial on how to set up OAuth 2.0. The documentation asks me to find the debug certificate fingerprint with the following command in the terminal:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
This doesn't work, I get the following error:
keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified.
What's the correct command on a Mac?
回答1:
The command provided in the tutorial works for Windows (apparently) but not for Mac. However, this one works like a charm on Macs:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
It adds the default password android
already in the command which saves one from typing. I hope Google will fix the documentation.
Output should look like:
Alias name: androiddebugkey
Creation date: 23 Nov 2019
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: C=US, O=Android, CN=Android Debug
Issuer: C=US, O=Android, CN=Android Debug
Serial number: 1
Valid from: Sat Nov 23 14:57:45 CET 2019 until: Mon Nov 15 14:57:45 CET 2049
Certificate fingerprints:
SHA1: xxxxxx
SHA256: xxxxxx
Signature algorithm name: SHA1withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 1
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /Users/cornelius/.android/debug.keystore -destkeystore /Users/cornelius/.android/debug.keystore -deststoretype pkcs12".
Credit: @JoeNCA https://stackoverflow.com/a/28350434/7483211
来源:https://stackoverflow.com/questions/59505659/getting-fingerprint-for-android-keystore-certificate-on-mac