1、生成自签https证书
keytool -genkey -v -alias serverKey -keyalg RSA -validity 3650 -keystore server.keystore
2、配置tomcat https
1、修改server.xml配置
到tomcat->conf->server.xml 打开编辑,找到如下Connector port="8443" 修改成如下keystoreFile 填写当前生成证书,keystorePass填写密码,保存。
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" keystoreFile="conf/ssl/server.keystore"
keystorePass="123456" />
2、重启服务 进入tomcat->bin
[root@VM_0_4_centos bin]# ./startup.sh
3、浏览器访问
https://localhost:8443
3、修改端口443 输入 https://localhost 可直接访问
tomcat https 默认8443端口,访问是需要带上8443端口,可修改成443,
1、吧redirectPort="8443" 修改redirectPort="443"
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
2、吧port ="8443" 修改port ="443"
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" keystoreFile="conf/ssl/server.keystore"
keystorePass="123456" />
3、重启服务
到tomcat->bin
[root@VM_0_4_centos bin]# ./startup.sh
4、浏览器访问
https://localhost