1炭懊、生成自簽https證書(shū)
keytool -genkey -v -alias serverKey -keyalg RSA -validity 3650 -keystore server.keystore
2、配置tomcat https
1、修改server.xml配置
到tomcat->conf->server.xml 打開(kāi)編輯,找到如下Connector port="8443" 修改成如下keystoreFile 填寫(xiě)當(dāng)前生成證書(shū)贝攒,keystorePass填寫(xiě)密碼,保存时甚。
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" keystoreFile="conf/ssl/server.keystore"
keystorePass="123456" />
2隘弊、重啟服務(wù) 進(jìn)入tomcat->bin
[root@VM_0_4_centos bin]# ./startup.sh
3哈踱、瀏覽器訪(fǎng)問(wèn)
https://localhost:8443
3、修改端口443 輸入 https://localhost 可直接訪(fǎng)問(wèn)
tomcat https 默認(rèn)8443端口梨熙,訪(fǎng)問(wèn)是需要帶上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、重啟服務(wù)
到tomcat->bin
[root@VM_0_4_centos bin]# ./startup.sh
4质欲、瀏覽器訪(fǎng)問(wèn)
https://localhost