本文翻译自:How to check certificate name and alias in keystore files?

I have a bunch of .keystore files and need to find one with specific CN and alias. 我有一堆.keystore文件,需要找到一个具有特定CN和别名的文件。 Is there a way to do it with keytool, jarsigner or some other tool? 有没有办法使用keytool,jarsigner或其他工具来做到这一点? I found a way to check if specific keystore was used to sign a specific apk, but I also need to get the alias and certificate name in each of the files. 我找到了一种检查特定密钥库是否用于签署特定apk的方法,但是我还需要在每个文件中获取别名和证书名称。


#1楼

参考:https://stackoom.com/question/s6Jf/如何检查密钥库文件中的证书名称和别名


#2楼

You can run the following command to list the content of your keystore file (and alias name): 您可以运行以下命令来列出密钥库文件的内容(和别名):

keytool -v -list -keystore .keystore

If you are looking for a specific alias, you can also specify it in the command: 如果要查找特定的别名,也可以在命令中指定它:

keytool -list -keystore .keystore -alias foo

If the alias is not found, it will display an exception: 如果找不到别名,它将显示异常:

keytool error: java.lang.Exception: Alias does not exist keytool错误:java.lang.Exception:别名不存在


#3楼

You can run from Java code. 您可以从Java代码运行。

try {File file = new File(keystore location);InputStream is = new FileInputStream(file);KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());String password = "password";keystore.load(is, password.toCharArray());Enumeration<String> enumeration = keystore.aliases();while(enumeration.hasMoreElements()) {String alias = enumeration.nextElement();System.out.println("alias name: " + alias);Certificate certificate = keystore.getCertificate(alias);System.out.println(certificate.toString());}} catch (java.security.cert.CertificateException e) {e.printStackTrace();} catch (NoSuchAlgorithmException e) {e.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} catch (KeyStoreException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}finally {if(null != is)try {is.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

Certificate class holds all information about the keystore. 证书类包含有关密钥库的所有信息。

UPDATE- OBTAIN PRIVATE KEY 更新-获取私钥

Key key = keyStore.getKey(alias, password.toCharArray());
String encodedKey = new Base64Encoder().encode(key.getEncoded());
System.out.println("key ? " + encodedKey);

@prateek Hope this is what you looking for! @prateek希望这是您想要的!


#4楼

KeyStore Explorer开源可视化工具来管理密钥库。


#5楼

为了获得所有详细信息,我必须在romaintaz答案中添加-v选项:

keytool -v -list -keystore <FileName>.keystore

#6楼

In a bash-like environment you can use: 在类似bash的环境中,可以使用:

keytool -list -v -keystore cacerts.jks | grep 'Alias name:' | grep -i foo

This command consist of 3 parts. 该命令包括3个部分。 As stated above, the 1st part will list all trusted certificates with all the details and that's why the 2nd part comes to filter only the alias information among those details. 如上所述, 第一部分将列出具有所有详细信息的所有受信任证书,这就是为什么第二部分开始仅过滤那些详细信息中的别名信息的原因。 And finally in the 3rd part you can search for a specific alias (or part of it). 最后,在第3部分中,您可以搜索特定的别名(或其中的一部分)。 The -i turns the case insensitive mode on. -i打开不区分大小写的模式。 Thus the given command will yield all aliases containing the pattern 'foo', fe foo, 123_FOO, fooBar, etc. For more information man grep . 因此,给定的命令将产生所有包含模式'foo',fe foo,123_FOO,fooBar等的别名。有关更多信息,请参见man grep

如何检查密钥库文件中的证书名称和别名?相关推荐

  1. android studio秘钥库文件不存在,获得SHA1以及错误java.lang.Exception: 密钥库文件不存在: keystore...

    一:在Android studio中Terminal中切换到相应的盘符下,我的jks文件在D盘,输入keytool -v -list -keystore myfirst.jks   "myf ...

  2. 百度地图调用 keytool 错误:java.lang.Exception: 密钥库文件不存在、getLocType 167(4.9E-324)错误

    百度地图调用中遇到的坑 1. keytool 错误:java.lang.Exception: 密钥库文件不存在 2.getLocType:167 错误 获取坐标(4.9E-324) 3.getAddr ...

  3. mac下keytool 错误: java.lang.Exception: 密钥库文件不存在

    最近项目需要上线, 其中一个项目 用旧项目改成新的, 在生打包的时候, 我忽略了一个问题, 导致项目还是之前的应用,找了一下发现没有改module里的applicationId没有改, 一定一定要改 ...

  4. keytool 错误: java.lang.Exception: 密钥库文件不存在: keystore

    keytool 错误: java.lang.Exception: 密钥库文件不存在: keystore 通过Android Studio编译器获取SHA1 第一步.打开Android Studio的T ...

  5. keytool 错误: java.lang.Exception: 密钥库文件存在, 但为空: E:\xxx\xxx\.jks

    android的报错提示:keytool 错误: java.lang.Exception: 密钥库文件存在, 但为空: E:\example\demo\arsdk.jks 错误在哪,可以发现: E:\ ...

  6. ldd命令 ubuntu_ldd命令,查看依赖的动态库信息 nm命令可以列出一个函数库文件中的符号表...

    ldd命令的作用是查看程序依赖的动态链接库信息.使用nm命令也可以获取库函数的信息:nm命令可以列出一个函数库文件中的符号表,它对静态的库函数和共享的库函数都能起作用. Linux动态库的默认搜索路径 ...

  7. 【XML文件数据预处理】获取xml文件中所有标签名称及数量||提取某个特定标签的数量||生成包含某个标签的图片索引txt并复制图片到指定文件夹

    目录 1.获取xml文件中所有标签名称及数量 2.提取某个特定标签的数量 3.生成包含某个标签的图片索引txt并复制图片到指定文件夹 1.获取xml文件中所有标签名称及数量 [需求]自己标注的数据集, ...

  8. 服务器端密钥库文件,使用密钥库文件为SOAP运行客户端WS

    该错误表示在您的信任库中找不到服务器证书.检查.keystore文件的内容以确定它是否包含服务器证书(在truststore中列为trustedEntry).如果是,请设置以下系统属性(使用-D JV ...

  9. java密钥库文件存在但为空_java安全套接层SSL示例

    1.建立密钥库: keytool -genkey -v -keyalg RSA -alias test -keystore sslkeystore 其中:-keyalg RSA表示密钥算法RSA,-a ...

最新文章

  1. Python一键转Java?“Google翻译”你别闹
  2. 海量分布式爬取抖音视频,几行代码搞定
  3. 力扣刷题流程-参考别人的经验觉得很有道理的
  4. 【CV】基于聚类的图像分割-Python
  5. 数学建论文模标准模板
  6. zoj1610-Count the Colors【线段树】
  7. new Class{}形式
  8. Qt常用类——QWidget
  9. Spring之@Configuration配置解析
  10. 正则表达式大全(汇总)
  11. 手动配置泛域名https (资源)
  12. 本地缓存需要高时效性怎么办_Android性能优化之关于缓存的构思
  13. 《构建高性能WEB站点》读书笔记--第一章
  14. LIO-SAM探秘第三章之代码解析(五) --- imuPreintegration.cpp
  15. access ribbon 编程_彻底玩转MS ACCESS 2016功能区编程设计(01)
  16. 自动驾驶工程师的进阶之路
  17. 沧小海基于xilinx srio核的学习笔记之第三章 xilinx srio核介绍(一)结构介绍
  18. 数据学习(十四)-方差分析与试验设计
  19. docker的目录挂载
  20. 矩形连乘问题c语言,矩阵连乘问题

热门文章

  1. Android JNI入门第四篇——jni头文件分析
  2. 动态代理之Rxjava/Retrofit应用实战
  3. 算法------ 两个链表的第一个公共节点
  4. 算法--------------------寻找两个有序数组的中位数
  5. Eclipse主题更换方法
  6. 【Android】AsyncTask原理应用及源码关键部分解析
  7. GIT中打标签(tag)的意义
  8. Android之底部菜单TabHost的实现
  9. swift_039(Swift中的KVC的使用方法)
  10. (0016)iOS 开发之Mac上Navicat Premium 创建远程连接和本地连接