利用JDK的keytool工具生成证书的DOS命令
陈琪
2023-12-01
1、生成服务器端证书:
E:\jdk1.6\bin>
keytool -genkey -v -alias tomcat -keyalg RSA -keystore D:/SSL/serv
er/tomcat.keystore -dname "CN=127.0.0.1,OU=pde,O=pde,L=Peking,ST=Peking,C=CN" -v
alidity 3650 -storepass pdepde -keypass pdepde
2、导出服务端证书:
E:\jdk1.6\bin>
keytool -export -alias tomcat -keystore d:/ssl/server/tomcat.keyst
ore -storepass pdepde -rfc -file d:/ssl/server/tomcat.cer
3、生成客户端证书:
E:\jdk1.6\bin>
keytool -genkey -v -alias client -keyalg RSA -storetype PKCS12 -ke
ystore D:/SSL/client/client.p12 -dname "CN=client,OU=pde,O=pde,L=bj,ST=bj,C=CN"
-validity 3650 -storepass client -keypass client
4、导出客户端证书:
E:\jdk1.6\bin>
keytool -export -alias client -keystore d:/ssl/client/client.p12 -
storetype PKCS12 -storepass client -rfc -file d:/ssl/client/client.cer
5、把客户端证书加入服务端证书信任列表:
E:\jdk1.6\bin>
keytool -import -alias client -v -file d:/ssl/client/client.cer -k
eystore d:/ssl/server/tomcat.keystore -storepass pdepde
6、生成客户端信任列表:
E:\jdk1.6\bin>
keytool -import -file d:/ssl/server/tomcat.cer -storepass pdepde -
keystore d:/ssl/client/client.truststore -alias tomcat -noprompt
[说明:证书生成目录D:/SSL/server/存放服务器端证书,D:/SSL/client/存放客户端证书]