1. 生成 keystore
2 : 有效期
<span style="font-size:18px;">$ keytool -genkey -alias android.keystore -keyalg RSA -validity 2 -keystore android.keystore
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: zhang
What is the name of your organizational unit?
[Unknown]: unit
What is the name of your organization?
[Unknown]: unit
What is the name of your City or Locality?
[Unknown]: bj
What is the name of your State or Province?
[Unknown]: bj
What is the two-letter country code for this unit?
[Unknown]: 10
Is CN=zhang, OU=unit, O=unit, L=bj, ST=bj, C=10 correct?
[no]: y
Enter key password for <android.keystore>
(RETURN if same as keystore password): </span>
2. 查看 keystore 里面的信息 :
$ keytool -list -v -keystore android.keystore
Enter keystore password:
or
$ keytool -list -v -keystore android.keystore -storepass pwssword
$ keytool -list -v -keystore android.keystore
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 1 entry
Alias name: android.keystore
Creation date: Jul 30, 2014
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=zhang, OU=unit, O=unit, L=bj, ST=bj, C=10
Issuer: CN=zhang, OU=unit, O=unit, L=bj, ST=bj, C=10
Serial number: 1e93686f
Valid from: Wed Jul 30 17:37:37 CST 2014 until: Fri Aug 01 17:37:37 CST 2014
Certificate fingerprints:
MD5: 81:C9:3D:D9:63:AB:A3:EB:E1:CF:92:92:51:EB:59:45
SHA1: 2B:30:F2:EE:0F:95:FE:EB:24:94:74:7C:00:C0:0F:A0:AC:91:71:9B
SHA256: 2D:A8:31:C7:92:94:E3:C1:02:9A:69:20:0D:B3:D7:D8:D4:37:C2:47:89:7C:4D:AB:7D:98:22:5F:25:02:86:B5
Signature algorithm name: SHA256withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 93 17 CF D9 E3 37 3E 2A 56 6D C8 CF A5 1F 3E B3 .....7>*Vm....>.
0010: 8E AD F2 BB ....
]
]
*******************************************
*******************************************
3. 签名:
jarsigner -verbose -keystore android.keystore -signedjar signed.apk unsigned.apk android.keystore