Tomcat 配置SSL

今天闲来无事,以前没有弄过SSL,准备试试。

1、也在网上搜了怎么使用的,首先用JAVA自带的KEYTOOLS 生成密钥

windows用户:

%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA


Unix用户

$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA

2、生成密钥以后,可以着手在配置文件里面加入SSL的配置了,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 className="org.apache.coyote.tomcat6.CoyoteConnector"
port="8443" minProcessors="5"
maxProcessors="75" enableLookups="true"
acceptCount="100"
protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="生成密钥的路径"
keystorePass="你设置密钥的密码" />


3、重启tomcat 访问
https://localhost:8443
,如能正确显示,则表示SSL配置成功。

4、最后,我表示很无聊,想了一下是不是web应用所有链接都可以转成HTTPS,找到了一段配置加入你应用的web.xml里面,即可为每个链接转换HTTPS,配置如下

<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted URLs</web-resource-name>
<url-pattern>/</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>


5、以上为自己配置的总结,实为自己随笔小记,第一次发帖,啥也不多说。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值