简体   繁体   English

如何创建csr、key、crt并将crt、rootca、subca导入jks?

[英]How to create csr, key, crt and import crt, rootca, subca into jks?

To overcome the doubt of expertise I just explain the process, by which we are able to generate csr and key ?为了克服专业知识的疑问,我只是解释了我们能够生成csr密钥的过程?

# generate a new private key and certificate signing request
openssl req -out chorke.csr -new -newkey rsa:2048 -nodes \
-keyout chorke.key

Please confirm us who is responsible for create crt either client or server ?请确认我们谁负责创建crt客户端服务器 Here we are acting as client and if we have to create crt from csr & key then we are able to create chorke.crt as following:在这里我们充当客户端,如果我们必须从csr密钥创建crt ,那么我们可以按如下方式创建chorke.crt

# generate certificate using csr & key
openssl x509 -req -in chorke.csr -signkey chorke.key \
-out chorke.crt

If the sever authority responsible for create chorke.crt then guide us the procedure?如果负责创建chorke.crt服务器权限然后引导我们的程序? Else we could send chorke.crt to sever authority to add it to their server.否则我们可以发送chorke.crt来切断将其添加到他们的服务器的权限。 After that the sever authority send us their rootca , subca (intermediate ca) and chorke.crt .之后,服务器权限向我们发送他们的rootcasubca (中间 ca)和chorke.crt Then we have to import them to a fresh client.jks as following:然后我们必须将它们导入到一个新的client.jks中,如下所示:

keytool -storepass storepasswd -importcert -keystore client.jks \
-trustcacerts -alias rootca -file rootca.cer

keytool -storepass storepasswd -importcert -keystore client.jks \
-trustcacerts -alias subca -file subca.cer

keytool -storepass storepasswd -importcert -keystore client.jks \
-alias chorke -file chorke.crt

After that we are ablie to run java program as following and causes bad certificate error之后我们可以按如下方式运行java程序导致证书错误

java \
-Djavax.net.ssl.trustStore=./client.jks \
-Djavax.net.ssl.trustStorePassword=storepasswd \
-Djavax.net.ssl.keyStore=./client.jks \
-Djavax.net.ssl.keyStorePassword=storepasswd \
-cp ./lib/*:./bin ChorkeServerTest

What's the wrong goes in this procedure as above?上面这个过程出了什么问题? In this situation we expect suggestion from expertise, to point out the errata and guide us the step from generation of csr to import into jks and run java program successfully.在这种情况下,我们期待专业人士的建议,指出勘误表并指导我们从生成csr到导入jks并成功运行java程序的步骤。

Please find in the below series of keytool and openssl commands used to create .jks file from .p12 certificate, extract/list the .jks key store configuration as part of .txt file, change the default alias to the expected alias, use openssl command to convert the .p12 certificate to .cer , configure/import the root-ca and intermediate-ca certificates as part of .jks key store file.请在以下系列中找到用于从.p12证书创建.jks文件的keytoolopenssl命令,提取/列出.jks密钥库配置作为.txt文件的一部分,将默认别名更改为预期别名,使用openssl命令要将.p12证书转换为.cer ,请将根 CA中间 CA证书配置/导入为.jks密钥库文件的一部分。

keytool command to create my_keystore.jks file with entry type as PrivateKeyEntry用于创建条目类型为PrivateKeyEntrymy_keystore.jks文件的keytool命令

keytool -importkeystore -srckeystore "D:\Certificates\DLOMTE.p12" -srcstoretype pkcs12 -destkeystore "my_keystore.jks" -deststoretype jks

keytool command to list/extract the my_keystore.jks configuration as my_keystore.txt file keytool命令列出/提取my_keystore.jks配置作为my_keystore.txt文件

keytool -list -v -keystore my_keystore.jks > my_keystore.txt

keytool command to change the default alias name in my_keystore.jks file keytool命令更改my_keystore.jks文件中的默认别名

keytool -changealias -alias "<ALIAS NAME AS IN THE KEYSTORE>" -destalias "at oces - prod" -keystore my_keystore.jks

openssl command to convert .p12 certificate to .cer.p12证书转换为.ceropenssl命令

openssl pkcs12 -in "D:\Certificates\DLOMTE.p12" -clcerts -nokeys -out "D:\Certificates\DLOMTE.cer"

keytool command to import the rootca certificate as part of my_keystore.jks file with required alias keytool命令导入rootca证书作为具有所需别名的my_keystore.jks文件的一部分

keytool -import -trustcacerts -alias "at oces - prod - rootca" -file "D:\Certificates\OCESPrimaryCA-RootCA.cer" -keystore my_keystore.jks

keytool command to import the intermediateca certificate as part of my_keystore.jks file with required alias keytool命令导入intermediateca证书作为具有所需别名的my_keystore.jks文件的一部分

keytool -import -trustcacerts -alias "at oces - prod - intermediateca" -file "D:\Certificates\OCESPrimaryCA-IntermediateCA.cer" -keystore my_keystore.jks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM