android:keytool签名查看md5指纹(java 15)

一,java8以后版本的keytool不再输出md5指纹信息

例子:
[lhdop@blog keystore]$ keytool -list -v -keystore poem.keystore
Enter keystore password:
Keystore type: PKCS12
Keystore provider: SUN
 
Your keystore contains 1 entry
 
Alias name: poem
Creation date: Apr 14, 2023
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=liuhongdi, OU=liuhongdi, O=liuhongdi, L=beijing, ST=beijing, C=86
Issuer: CN=liuhongdi, OU=liuhongdi, O=liuhongdi, L=beijing, ST=beijing, C=86
Serial number: 8028dc6750c99e58
Valid from: Fri Apr 14 09:33:04 CST 2023 until: Sun Mar 21 09:33:04 CST 2123
Certificate fingerprints:
         SHA1: A1:23:05:8A:5E:3B:9C:8D:03:E5:F5:CB:67:E8:A7:8A:4C:92:07:A2
         SHA256: 0F:40:91:72:FD:5A:F2:04:2F:38:1E:80:7F:87:C2:96:44:5B:BD:1F:BA:11:FB:FF:15:7F:55:77:FC:24:AB:C9
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3
 
Extensions:
 
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: C5 B9 7B C9 EA 27 8A 9D   86 49 AB 19 C7 18 F0 91  .....'...I......
0010: 13 52 CB 40                                        .R.@
]
]
 
 
 
*******************************************
*******************************************

说明:可以看到在证书指纹一项下面,只有SHA1和SHA256两项,没有MD5

二,用openssl转换生成md5:

第一个解决办法是切换到jdk 1.7.x,jdk 1.6.x,
第二个方法:如果不想切换jdk版本,在linux环境下可以使用openssl命令来获取md5值
 
1,查看是否存在openssl命令?
[lhdop@blog keystore]$ openssl version
OpenSSL 1.1.1c FIPS  28 May 2019 
如openssl命令不存在,用yum安装:
yum install openssl openssl-devel
2,通过openssl获取md5字符串
[lhdop@blog keystore]$ keytool -exportcert -alias poem -storepass testpass -keystore poem.keystore | openssl dgst -md5
(stdin)= 1b2828dd49b64ba5bf1424cfed983019
字符串加冒号:
[lhdop@blog keystore]$ keytool -exportcert -alias poem -storepass testpass -keystore poem.keystore | openssl dgst -md5 | sed 's/[a-fA-F0-9][a-fA-F0-9]/&:/g; s/:$//'
(stdin)= 1b:28:28:dd:49:b6:4b:a5:bf:14:24:cf:ed:98:30:19

说明:刘宏缔的架构森林是一个专注架构的博客,

网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/06/05/android-keytool-qian-ming-zha-kan-md5-zhi-wen-java-15/

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

三,查看java的版本:

[lhdop@blog keystore]$ java --version
java 15 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

 

posted @ 2023-04-14 14:20  刘宏缔的架构森林  阅读(2174)  评论(0编辑  收藏  举报