【问题标题】:Confusion generating private and public keys for jsse?混淆为 jsse 生成私钥和公钥?
【发布时间】:2014-08-16 13:33:24
【问题描述】:

我找到了介绍生成密钥步骤的教程。 它讲述了以下步骤:

keytool -genkey -alias clientprivate -keystore client.private -storetype JKS -keyalg rsa \
    -dname "CN=Your Name, OU=Your Organizational Unit, O=Your Organization, L=Your City, \
    S=Your State, C=Your Country" -storepass clientpw -keypass clientpw

keytool -genkey -alias serverprivate -keystore server.private -storetype JKS -keyalg rsa \
   -dname "CN=Your Name, OU=Your Organizational Unit, O=Your Organization, L=Your City, \
   S=Your State, C=Your Country" -storepass serverpw -keypass serverpw

keytool -export -alias clientprivate -keystore client.private \
    -file temp.key -storepass clientpw

keytool -import -noprompt -alias clientpublic -keystore client.public \
    -file temp.key -storepass public

keytool -export -alias serverprivate -keystore server.private \
    -file temp.key -storepass serverpw
keytool -import -noprompt -alias serverpublic -keystore server.public \
   -file temp.key -storepass public

但我很困惑 .jks 文件在哪里?为什么我们使用 temp.key? 你可以回答我的问题,我将不胜感激......

【问题讨论】:

  • 这个问题似乎离题了,因为它与编程无关。也许Super User 会是一个更好的提问地点。
  • @jww 这是关于keytool的,它是JDK的一部分。这里有数百个类似的问题。
  • @EJP - 其中一些可能也离题了。社区有时在自我监管和执行自己的政策方面做得很差。

标签: java ssl ssl-certificate jsse truststore


【解决方案1】:

最终,.keystore.jks 只是文件扩展名:您可以合理地命名文件。一些应用程序使用存储在$HOME/.keystore 中的密钥库文件:通常暗示它是一个JKS 文件,因为JKS is the default keystore type in the Sun/Oracle Java security provider。不是每个人都对 JKS 文件使用 .jks 扩展名,因为它是默认的。我建议使用扩展,只是为了记住要指定的类型(如果需要)。

在 Java 中,单词 keystore 可以具有以下任一含义,具体取决于上下文:

当谈到文件和存储时,这并不是真正的键/值对存储工具(有很多或其他格式)。相反,它是一个存储加密密钥和证书的容器(我相信其中一些也可以存储密码)。通常,这些文件是加密的并受密码保护,以免这些数据提供给未经授权的各方。

Java 使用其KeyStore 类和相关 API 来使用密钥库 (whether it's file based or not)。 JKS 是一种特定于 Java 的文件格式,但该 API 也可以用于其他文件类型,通常是 PKCS#12。当您要加载密钥库时,您必须指定其密钥库类型。常规的扩展是:

  • .jks 类型为 "JKS"
  • .p12.pfx 用于类型 "PKCS12"(规范名称为 PKCS#12,但 Java 密钥库类型名称中未使用 #)。

此外,BouncyCastle 还提供了它的实现,特别是 BKS(通常使用 .bks 扩展名),它经常用于 Android 应用程序。

你对此感到困惑。

keystore 是证书、私钥等的容器。

此密钥库的格式有规范,主要是#PKCS12

JKS 是 Java 的密钥库实现。还有BKS等。

这些都是密钥库类型

所以回答你的问题:

.keystore 文件和 .jks 文件的区别

没有。 JKS 是密钥库文件。 虽然密钥库 类型 之间存在差异。例如。 JKS#PKCS12

这可能会对您有所帮助。

http://ankursinghal86.blogspot.in/2014/06/authentication-with-client-certificate.html

【讨论】:

    【解决方案2】:

    .jks 文件在哪里?

    前两个操作在您的 $HOME/.keystore 上运行。

    为什么我们使用 temp.key?

    作为中间文件从服务器环境携带到客户端环境进行导入,反之亦然。携带 .keystore 文件本身会危及私钥,因此不安全。导出步骤不会导出私钥。

    【讨论】:

      猜你喜欢
      • 2020-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 2022-01-13
      • 2019-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多