java - SSL : CSR file created with openSSL and installing with keytool

标签 java tomcat ssl https openssl

我已经使用命令 openSSL 创建了 CSR 并购买了 crt 文件。

openssl genrsa -out private-key.pem 2048 
openssl req -new -key private-key.pem -out csr.pem

因为我没有使用 keytool 创建 CSR 文件(但使用 openSSL 创建),所以使用 keystore 命令安装它可以吗?

另一个问题是我从受信任的证书生成公司那里得到了三个文件。那么如何识别哪个是主要的、根的、中间的crt文件呢?文件名本身未提及文件类型(root,intermediate)。我必须根据 crt 文件类型运行以下命令。

keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file [name of the root certificate]

keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file [name of the intermediate certificate]

keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file [name of the certificate]

最佳答案

Will it be OK to install this by using keystore command as I have not created CSR file by using keytool (but created using openSSL) ?

您还必须将私钥导入 keystore 。否则 keystore 将毫无用处。

有两种方法:

  1. 首先使用 OpenSSL 创建一个 PKCS#12 文件,然后使用 key 工具将此文件转换为 JKS(参见 here)。
  2. 使用KeyStore Explorer ,它具有 OpenSSL 格式的导入/导出功能。可以找到说明here .

Another question is I have got three files from the trusted certificate generation company. So how to indentify which one is primary, root, intermediate crt files ?

您必须查看证书的内容,尤其是它们的专有名称 (DN)。

  • 根 CA 证书始终具有相同的 SubjectDN 和 IssuerDN。
  • 中间 CA 将根 CA 的 SubjectDN 作为其 IssuerDN 和一个不同的 SubjectDN。
  • SSL 证书将中间 CA 的 SubjectDN 作为其 IssuerDN,并将域名作为其 SubjectDN 的一部分。

用于打印 SubjectDN 和 IssuerDN 的 OpenSSL 命令取决于证书文件的格式(DER 或 PEM)。 DER是二进制格式,PEM是ASCII格式。如果您不确定,请同时尝试:

openssl x509 -noout -subject -issuer -nameopt RFC2253 -inform DER -in <cert-file>

openssl x509 -noout  -subject -issuer -nameopt RFC2253 -inform PEM -in <cert-file>

关于java - SSL : CSR file created with openSSL and installing with keytool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31871783/

相关文章:

java - 程序关闭后事务是否结束?

ssl - Arduino 可以安全地连接到 MQTT 吗?

java - 封装和/或组织数据的策略

Java JSpinner 用向下箭头增加值

tomcat - Tomcat 5.0 上的 JSTL C 标签库

java - JSP Tomcat 不良资源

cocoa - 在一个 CFReadStream 中设置 kCFStreamSSLValidatesCertificateChain 会导致其他 CFReadStreams 不验证证书链

ssl - Docker 容器 SSL 证书

java - 需要帮助修复我的 Java 代码,将字母电话号码转换为完整的数字等效项

java - liferay 门户内部有哪些技术