tomcat下配置https

打开终端,在命令行依次运行下面命令,按提示操作
1.为服务器生成证书
keytool -genkey -v -alias tomcat -keyalg RSA -keystore /home/show/my/tomcat.keystore -validity 36500

2.为客户端生成证书
keytool -genkey -v -alias mykey -keyalg RSA -storetype PKCS12 -keystore /home/show/my/mykey.p12

3.让服务器信任客户端证书
keytool -export -alias mykey -keystore /home/show/my/mykey.p12 -storetype PKCS12 -storepass 111111 -rfc -file /home/show/my/mykey.cer

4.让客户端信任服务器证书
keytool -keystore /home/show/my/tomcat.keystore -export -alias tomcat -file /home/show/my/tomcat.cer

5.配置Tomcat服务器
Tomcat目录下找到server.xml,找到下面‘port="8443"’信息,并修改为如下:
SSLEnabled="true" maxThreads="150" scheme="https"
secure="true" clientAuth="false" sslProtocol="TLS"
keystoreFile="/home/show/my/tomcat.keystore" keystorePass="111111"/>

  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓