如何从 cer 文件创建密钥库? [英] How to create keystore from cer files?
问题描述
我在从 cer 文件创建密钥库时遇到问题.
I have a problem with the creation of keystore from cer files.
我有三个文件:
- 名称Certyfikat2015.cer
- NameIntermediateCA.cer
- NamePrivateKey.txt
我想获取 jks Keystore 文件.如何使用 keytool 执行此操作?我需要该文件用于 Wildfly 容器.
And I want to get jks Keystore file. How can I do this using keytool? I need that file for wildfly container.
我的 NamePrivateKey.txt 开头为:
My NamePrivateKey.txt start with:
-----BEGIN RSA PRIVATE KEY-----
推荐答案
添加 4/21:发现重复:
ADDED 4/21: Found duplicates:
keytool
不直接处理私钥.
正常过程是:
keytool -genkeypair
私钥和公钥在一个JKSkeytool -certreq
从那个密钥对生成一个CSR- 将 CSR(和相关证据)发送给 CA 以获得证书
keytool -importcert
证书,加上任何所需的中间或链"证书,进入 相同 JKS
keytool -genkeypair
the privatekey and publickey in a JKSkeytool -certreq
generate a CSR from that keypair- send the CSR (and related evidence) to a CA to get a certificate
keytool -importcert
the certificate, plus any needed intermediate or "chain" certficate(s), into the same JKS
如果您没有包含 privateKey 的 JKS,但您的 PrivateKey.txt 文件包含 openssl 可用格式的私钥 - 它是否以 -----BEGIN
行后跟一些 base64 行和匹配的 -----END
行,如果是这样,那么以 BEGIN 命名的类型是什么?-- 如果你有或者得到了openssl,你可以使用openssl把私钥和相关证书组合成一个PKCS#12文件,然后keytool
就可以转换PKCS#12 到这样的 JKS:
If you don't have the JKS with the privateKey in it, but your PrivateKey.txt file contains the private key in a format usable by openssl -- does it begin with a -----BEGIN
line followed by some lines of base64 and a matching -----END
line and if so what is the type named after BEGIN? -- and you have or get openssl, you can use openssl to combine the privatekey and the related certs into a PKCS#12 file, and then keytool
can convert the PKCS#12 to a JKS like this:
keytool -importkeystore -srckeystore p12file -srcstoretype pkcs12 -destkeystore jksfile
或根据 https://issues.jboss.org/browse/WFLY-3686(足够新?)Wildfly 可以按原样使用 PKCS12 密钥库(代替 JKS).
Or according to https://issues.jboss.org/browse/WFLY-3686 (sufficiently recent?) Wildfly can use a PKCS12 keystore as-is (instead of JKS).
编辑 4/21:openssl pkcs12
实用程序的文档在您系统的手册页中,如果安装了 OpenSSL 的类 Unix(通常是第 1ssl 部分或类似部分),或者在 https://www.openssl.org/docs/apps/pkcs12.html#FILE-CREATION-OPTIONS,或者在上面的副本中,或者还有 将 CERT/PEM 证书转换为 PFX 证书
EDIT 4/21: Documentation for the openssl pkcs12
utility is in a man page on your system if Unix-like with OpenSSL installed (typically section 1ssl or similar), or online at https://www.openssl.org/docs/apps/pkcs12.html#FILE-CREATION-OPTIONS, or in the duplicates above, or also Convert a CERT/PEM certificate to a PFX certificate
这篇关于如何从 cer 文件创建密钥库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!