configuring tomcat to support SSL

This is a short guide about configuring tomcat to support SSL and run portal over https.

BR,
Hamid

Source: http://stackoverflow.com/questions/1180397/tomcat-server-client-self-signed-ssl-certificate

- Install latest tomcat (I use 7.0.8). There is no separate "SSL support" version. It's already included.
- Create a folder in tomcat directory (lets say "cert"): C:\Programs\apache-tomcat-7.0.
8\cert
- Cd into "cert", and run these commands in a windows prompt. You need to either have java bin folder in your path, or specify the full path to keytool (for example "C:\Program Files\Java\jdk1.7.0_07\bin\
keytool")

    keytool -genkeypair -alias servercert -keyalg RSA -dname "CN=Web Server,OU=Unit,O=Organization,
L=City,S=State,C=US" -keypass password -keystore server.jks -storepass password  -validity 3650
    keytool -genkeypair -alias tomcat -keystore tomcat.p12 -storetype pkcs12 -keyalg RSA -dname "CN=tomcat,OU=Unit,O=
Organization,L=City,S=State,C= US" -keypass password -storepass password -validity 3650
    keytool -exportcert -alias tomcat -file tomcat.cer -keystore tomcat.p12 -storetype pkcs12 -storepass password
    keytool -importcert -keystore server.jks -alias tomcat -file tomcat.cer -v -trustcacerts -noprompt -storepass password
    keytool -list -v -keystore server.jks -storepass password
    del tomcat.cer

- Check that you have these files in "cert":
server.jks
tomcat.p12

- Edit C:\Programs\apache-tomcat-7.0.
8\conf\server.xml and add a new connector:

<Connector protocol="org.apache.coyote.
http11.Http11NioProtocol"
           port="8443" SSLEnabled="true"
           maxThreads="200" scheme="https" secure="true"
           keystoreFile="\cert\server.
jks" keystorePass="password"
           clientAuth="false" sslProtocol="TLS" />

- Start tomcat.

Now in a browser, instead of usual URL:
http://localhost/portal-root-war/index_mock.html?deviceId=82:64:61:79:68:69&type=plain

Try https (don't forget to add port 8443):
https://localhost:8443/portal-root-war/index_mock.html?deviceId=82:64:61:79:68:69&type=plain

Now portal should be loaded and all requests should be over https!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值