LINUX

关注公众号 jb51net

关闭
操作系统 > LINUX >

Linux CentOS系统下tomcat配置ssl教程

脚本之家

今天给公司同事要求在内部测试服务器上,让tomcat支持ssl,本来我以为是在apache上配置,原来tomcat自己都可以配置ssl,来看教程吧.

系统:centos 5.5
需要的软件:jdk-6u32-linux-i586-rpm.bin
           apache-tomcat-6.0.36.tar.gz

1.安装前准备



wget http://apache.etoak.com/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.tar.gz
wget http://download.slogra.com/java/jdk-6u32-linux-i586.bin


2.安装jdk

大家可以去看centos安装jdk 1.6这篇文章.

3.安装tomcat


tar zxf apache-tomcat-6.0.36.tar.gz -c /usr/local
cd /usr/local
mv apache-tomcat-6.0.36 tomcat && cd tomcat
./bin/startup.sh

然后在浏览器输入:http://localhost:8080看看那只"猫"是否出来了.

4.配置SSL



cd /usr/java/jdk1.6.0_32/bin
./keytool -genkey -alias tomcat -keyalg RSA -keystore /usr/local/tomcat/conf/.keystore

输入密码、提供你的信息即可.

5.修改tomcat配置文件



cd /usr/local/tomcat/conf/
vi server.xml

找到这一段:


<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />

修改为:


<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" keystoreFile="/usr/local/tomcat6-ccms/conf/.keystore" keystorePass="monstar" sslProtocol="TLS" />

6.重启tomcat


/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh

防火墙开启8443端口,然后在浏览器输入:https://ip:8443/,好了可以安全的看到那只"猫"了.