1、keytool的指令tomcat
Java 中的 keytool.exe (位于JDK\Bin 目录下)能够用来建立数字证书,全部的数字证书是以一条一条(采用别名区别)的形式存入证书库的中,证书库中的一条证书包含该条证书的私钥,公钥和对应的数字证书的信息。证书库中的一条证书能够导出数字证书文件,数字证书文件只包括主体信息和对应的公钥,Keytool是一个Java数据证书的管理工具。 服务器
二. 建立证书 1.建立证书中的参数说明 工具
1.密钥库的密码至少必须6个字符,能够是纯数字或者字母或者数字和字母的组合等等server
三.查看密钥库里面的证书xml
查看test.keystore这个密钥库里面的全部证书: keytool -list -keystore test.keystore 图片
四.导出证书文件ssl
将名为test.keystore的证书库中别名为keypair的证书条目导出到证书文件test.crt中: keytool -export -alias keypair -file test.crt -keystore test.keystore get
五.导入证书 将证书文件test.crt导入到名为test_cacerts的证书库中: keytool -import -keystore test_cacerts -file test.crtit
六.查看证书 查看证书文件test.crt的信息: keytool -printcert -file test.crttest
七.删除密钥库中的条目
删除密钥库test.keystore中别名为keypair的证书条目: keytool -delete -keystore test.keystore -alias keypair
8、修改证书条目的口令
将密钥库test.keystore中别名为test1的证书条目的密码修改成12345689 keytool -keypasswd -alias test1 -keystore test.keystore
总结: 实际生成证书的主要为: 1.在jdk目录下,打开keytool 而后输入命令:keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "D:\tomcat.keystore"
将生产一对非对称密钥和自我签名的证书D:\tomcat.keystore
2.而后再输入命令: keytool -export -alias tomcat -file tomcat.crt –keystore "D:\tomcat.keystore"
会导出证书文件tomcat.crt,这个为证书文件也就是须要安装到受信任的根证书目录
3.修改tomcat路径conf目录下的server.xml文件,去掉注释并修改如下内容:
<Connectorport="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150"scheme="https" secure="true" clientAuth="false"sslProtocol="TLS" keystoreFile="D:\tomcat\tomcat.keystore"keystorePass="123456"
/>
开启SSL协议
4.而后再去访问tomcat服务器,https://localhost:8443/,会提示安装证书: