我找到了介绍 key 生成步骤的教程。 它讲述了以下步骤:
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? 如果您能回答我的问题,我将不胜感激...
最佳答案
最终,.keystore
和 .jks
只是文件扩展名:您可以合理地命名您的文件。某些应用程序使用存储在 $HOME/.keystore
中的 keystore 文件:通常暗示它是 JKS 文件,因为 JKS is the default keystore type in the Sun/Oracle Java security provider .并不是每个人都对 JKS 文件使用 .jks
扩展名,因为这是默认设置。我建议使用扩展名,只是为了记住要指定的类型(如果需要)。
在 Java 中,keystore 这个词可以有以下任一含义,具体取决于上下文:
- API:http://docs.oracle.com/javase/6/docs/api/java/security/KeyStore.html
- 可用于支持此 API 的文件(或其他机制)
- keystore 而不是信任库,如下所述:https://stackoverflow.com/a/6341566/372643
当谈到文件和存储时,这并不是真正的键/值对存储工具(有很多或其他格式)。相反,它是一个存储 key 和证书的容器(我相信其中一些也可以存储密码)。通常,这些文件都经过加密和密码保护,以免未经授权的各方获得这些数据。
Java 使用它的 KeyStore
类和相关 API 以使用 keystore (whether it's file based or not)。 JKS
是一种特定于 Java 的文件格式,但该 API 也可用于其他文件类型,通常是 PKCS#12。当你想加载一个 keystore 时,你必须指定它的 keystore 类型。常规扩展名是:
.jks
类型"JKS"
,.p12
或.pfx
类型"PKCS12"
(规范名称是 PKCS#12,但#
未在 Java keystore 类型名称中使用。
此外,BouncyCaSTLe 还提供了它的实现,特别是 BKS (通常使用 .bks
扩展名),它经常用于 Android 应用程序。
你对此感到困惑。
keystore
是证书、私钥等的容器。
这个 keystore 的格式有规范,主要是 #PKCS12。
JKS 是 Java 的 keystore 实现。还有BKS等
这些都是 keystore 类型。
所以回答你的问题:
difference between .keystore files and .jks files
没有。 JKS 是 keystore 文件。
keystore 类型之间存在差异。例如。 JKS
与 #PKCS12
这可能会帮助您开始。
http://ankursinghal86.blogspot.in/2014/06/authentication-with-client-certificate.html
关于java - 混淆生成 jsse 的私钥和公钥?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24417960/