keytool -genkey -v -alias tomcat -keyalg RSA -keystore tomcat.keystore -dname "CN=127.0.0.1,OU=sy,O=sy,L=sy,ST=ln,C=cn" -validity 3650 -storepass 123456 -keypass 123456
生成证书库tomcat.keystore
Tomcat根目录下的/conf/server.xml
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/etc/tomcat.keystore" keystorePass="123456"/>
注:(1)证书库tomcat.keystore放在Tomcat根目录下的/ etc /下,etc为我自己建立的文件夹。
(2)访问地址:https://127.0.0.1:8443/
keytool -genkey -v -alias tomcat -keyalg RSA -keystore tomcat.keystore -dname "CN=127.0.0.1,OU=sy,O=sy,L=sy,ST=ln,C=cn" -validity 3650 -storepass 123456 -keypass 123456
生成证书库tomcat.keystore
keytool -genkey -v -alias ceshi -keyalg RSA -storetype PKCS12 -keystore ceshi.p12 -dname "CN=ceshi,OU=sy,O=sy,L=sy,ST=ln,C=cn " -validity 3650 -storepass 123456 -keypass 123456"
keytool -export -alias ceshi -keystore ceshi.p12 -storetype PKCS12 -storepass 123456 -rfc -file ceshi.cer
keytool -import -alias ceshi -v -file ceshi.cer -keystore tomcat.keystore -storepass 123456
Tomcat根目录下的/conf/server.xml
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="true" sslProtocol="TLS"
keystoreFile="/etc/tomcat.keystore" keystorePass="123456"
truststoreFile="/etc/tomcat.keystore" truststorePass="123456"
truststoreType="JKS"/>
注:(1)服务端证书库和信任证书库同时用tomcat.keystore放在Tomcat根目录下的/ etc /下,etc为我自己建立的文件夹。
(2) 双向认证需要设置clientAuth="true",则需要强制验证客户端证书。客户端必须安装“ceshi.p12”,导入ceshi.p12导入IE。
(3)访问地址:https://127.0.0.1:8443/。