java - 使用 keytool [Windows 7] 在 jre 中导入 .pem 文件

标签 java ssl keytool digital-certificate

我有 .pem 文件来访问 https url,但我无法将其导入本地 JDK,我不确定 keytool 应该接受哪种格式(.pem、.der、.cer、.jks、或.cer)。

我找到了一些解决方案,但它们使用的是 openssl,Import PEM into Java Key Store但我必须使用 keytool,

而且,当我在 CMD 上执行“keytool -list”命令时,它给我异常 keytool error: java.lang.Exception: Keystore file does not exist:

谁能给我在 jre 中导入 .pem 文件的步骤

谢谢,

最佳答案

您的意思是,您想将 .pem 文件导入 JRE 信任库?信任库文件位于 %JAVA_HOME%\jre\lib\security\cacerts。默认密码是“changeit”。

Keytool 也接受 .pem 证书,因此您无需将其转换为其他格式。只需执行以下导入命令,

keytool -import -alias <PROVIDE_UNIQUE_CERTIFICATE_ALIAS_HERE> -file <PATH_TO_PEM_FILE> -keystore <JRE_TRUSTSTORE_FILE> -storepass <TRUSTSTORE_PASSWORD>

And also, When i execute "keytool -list" command on CMD, its giving me exception keytool error: java.lang.Exception: Keystore file does not exist:

您需要指定 keystore 路径以及 keystore 密码,

keytool -list -keystore <JRE_TRUSTSTORE_FILE> -storepass <TRUSTSTORE_PASSWORD>

如果您想了解有关 keytool 命令的更多信息,以下链接可能是您最好的伙伴,

https://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html

关于java - 使用 keytool [Windows 7] 在 jre 中导入 .pem 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44249215/

相关文章:

Windows 上的 Android 签名应用程序

javascript - 覆盖 Javascript 文件 Maven

java - CamelContext.start() 不会阻塞

java - 是否可以编写跨数据库连接查询?

java - jasper 报告什么也不显示,并在 Netbeans 上收到错误 NullPointer 错误

javascript - 使用 node.js 调试 TLS 客户端连接

java - SSL 握手异常 :no cipher suites in common

openssl - TLS/SSL 中的消息完整性

ssl - Fluentd SSL/TLS 保护通用接收器 (Logstash) 的 TCP 输出插件?

java - keytool如何保护 key ?