<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-124  評論-194  文章-0  trackbacks-0

    Setting Up SSL on Tomcat in 5 minutes (https://localhost:8443)

    June 30, 2011 | By 

    This tutorial will walk you through how to configure SSL (https://localhost:8443 access) on Tomcat in 5 minutes.

    apache tomcat Setting Up SSL on Tomcat in 5 minutes (https://localhost:8443)

    For this tutorial you will need:

    • Java SDK (used version 6 for this tutorial)
    • Tomcat (used version 7 for this tutorial)

    The set up consists in 3 basic steps:

    1. Create a keystore file using Java
    2. Configure Tomcat to use the keystore
    3. Test it
    4. (Bonus ) Configure your app to work with SSL (access through https://localhost:8443/yourApp)

    1 – Creating a Keystore file using Java

    Fisrt, open the terminal on your computer and type:

    Windows:

    cd %JAVA_HOME%/bin 

    Linux or Mac OS:

    cd $JAVA_HOME/bin 

    The $JAVA_HOME on Mac is located on “/System/Library/Frameworks/JavaVM.framework/Versions/{your java version}/Home/

    You will change the current directory to the directory Java is installed on your computer. Inside the Java Home directory, cd to the bin folder. Inside the bin folder there is a file named keytool. This guy is responsible for generating the keystore file for us.

    Next, type on the terminal:

    keytool -genkey -alias tomcat -keyalg RSA 

    When you type the command above, it will ask you some questions. First, it will ask you to create a password (My password is “password“):

    loiane:bin loiane$ keytool -genkey -alias tomcat -keyalg RSA Enter keystore password:  password Re-enter new password: password What is your first and last name?   [Unknown]:  Loiane Groner What is the name of your organizational unit?   [Unknown]:  home What is the name of your organization?   [Unknown]:  home What is the name of your City or Locality?   [Unknown]:  Sao Paulo What is the name of your State or Province?   [Unknown]:  SP What is the two-letter country code for this unit?   [Unknown]:  BR Is CN=Loiane Groner, OU=home, O=home, L=Sao Paulo, ST=SP, C=BR correct?   [no]:  yes  Enter key password for 	(RETURN if same as keystore password):  password Re-enter new password: password 

    It will create a .keystore file on your user home directory. On Windows, it will be on: C:\Documents and Settings\[username]; on Mac it will be on /Users/[username] and on Linux will be on /home/[username].

    2 – Configuring Tomcat for using the keystore file – SSL config

    Open your Tomcat installation directory and open the conf folder. Inside this folder, you will find the server.xml file. Open it.

    Find the following declaration:

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

    Uncomment it and modify it to look like the following:

    Connector SSLEnabled="true" acceptCount="100" clientAuth="false"     disableUploadTimeout="true" enableLookups="false" maxThreads="25"     port="8443" keystoreFile="/Users/loiane/.keystore" keystorePass="password"     protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https"     secure="true" sslProtocol="TLS" /> 

    Note we add the keystoreFilekeystorePass and changed the protocol declarations.

    3 – Let’s test it!

    Start tomcat service and try to access https://localhost:8443. You will see Tomcat’s local home page.

    Note if you try to access the default 8080 port it will be working too: http://localhost:8080

    4 – BONUS - Configuring your app to work with SSL (access through https://localhost:8443/yourApp)

    To force your web application to work with SSL, you simply need to add the following code to your web.xml file (before web-app tag ends):

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

    The url pattern is set to /* so any page/resource from your application is secure (it can be only accessed with https). The transport-guarantee tag is set to CONFIDENTIAL to make sure your app will work on SSL.

    If you want to turn off the SSL, you don’t need to delete the code above from web.xml, simply changeCONFIDENTIAL to NONE.

    Referencehttp://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html (this tutorial is a little confusing, that is why I decided to write another one my own).

    Happy Coding!

    posted on 2012-11-12 23:17 我愛佳娃 閱讀(3192) 評論(0)  編輯  收藏 所屬分類: SSL
    主站蜘蛛池模板: 国产免费无码AV片在线观看不卡| 特级毛片全部免费播放| 精品成人免费自拍视频| 亚洲夜夜欢A∨一区二区三区| 国产成人亚洲精品蜜芽影院| 国产福利免费观看| 成a人片亚洲日本久久| 国产精品另类激情久久久免费| 亚洲欧美日韩综合久久久| 日本免费中文字幕在线看| 久久亚洲AV成人无码国产最大| 国产成人免费a在线视频app| 相泽南亚洲一区二区在线播放| 免费国产成人高清在线观看麻豆| 在线观看亚洲免费| 亚洲综合亚洲综合网成人| 你懂的免费在线观看| 亚洲AV人无码综合在线观看| 亚洲精品视频在线免费| 亚洲免费福利在线视频| 国产美女精品视频免费观看| 免费无毒a网站在线观看| 亚洲伊人色欲综合网| 无码AV片在线观看免费| 亚洲成aⅴ人在线观看| 成人超污免费网站在线看| 色偷偷亚洲第一综合网| 国产亚洲精品a在线观看 | 精品香蕉在线观看免费| 中文字幕无码精品亚洲资源网久久| 日韩电影免费在线观看视频| 特级做a爰片毛片免费看| 亚洲第一AV网站| 成年人免费网站在线观看| 国产亚洲男人的天堂在线观看| 国产亚洲精品影视在线产品| 1000部啪啪未满十八勿入免费| 亚洲日本天堂在线| 亚洲精品字幕在线观看| 永久免费av无码不卡在线观看 | 亚洲成A人片在线观看中文|