【问题标题】:import .pem file in jre using keytool [Windows 7]使用 keytool [Windows 7] 在 jre 中导入 .pem 文件
【发布时间】:2017-10-30 03:50:04
【问题描述】:

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

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

而且,当我在 CMD 上执行“keytool -list”命令时,它给了我异常 keytool 错误:java.lang.Exception: Keystore 文件不存在:

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

谢谢,

【问题讨论】:

    标签: java ssl keytool digital-certificate


    【解决方案1】:

    您的意思是,您想将 .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>
    

    而且,当我在 CMD 上执行“keytool -list”命令时,它给了我 异常 keytool 错误:java.lang.Exception:密钥库文件没有 存在:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-29
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 2013-02-12
      • 2011-05-17
      • 2016-10-02
      • 1970-01-01
      相关资源
      最近更新 更多