Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Monday, April 6, 2015

Https - Configure SSL/HTTPS support on Apache Tomcat 7

■ Configure SSL/HTTPS support on Tomcat 7
 -(sample-test.sample.local -> sample)
 -(JKS -> Java KeyStore)
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool -genkey -alias sample -keyalg RSA -keystore /Users/kim_joon/tomcat/conf/sample.jks
Enter keystore password:   # -> sample
Re-enter new password: # -> sample
What is your first and last name?
  [Unknown]:  Joon Kim
What is the name of your organizational unit?
  [Unknown]:  sample
What is the name of your organization?
  [Unknown]:  sample
What is the name of your City or Locality?
  [Unknown]:  tokyo
What is the name of your State or Province?
  [Unknown]:  shibuya
What is the two-letter country code for this unit?
  [Unknown]:  jp
Is CN=Joon Kim, OU=sample, O=sample, L=tokyo, ST=shibuya, C=jp correct?
  [no]:  yes

Enter key password for <sample>
(RETURN if same as keystore password):                                                    # -> testtest
Re-enter new password:        # -> testtest


■ For confirming a JKS file
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool -list -keystore /Users/kim_joon/tomcat/conf/sample.jks
Enter keystore password:     # -> sample

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

cyberagent, Apr 6, 2015, PrivateKeyEntry,
Certificate fingerprint (SHA1): 9F:36:89:8E:B5:06:86:20:B3:47:BF:E4:94:87:0F:C0:FF:87:A9:C4

■ Configure the server.xml in Tomcat7.
 @Before
    <!-- $TOMCAT_HOME/conf/server.xml -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
 @After
    <!-- $TOMCAT_HOME/conf/server.xml -->
    <Connector port="8443" protocol="HTTP/1.1"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="conf/sample.jks"
               keystoreType="JKS"
               keystorePass="sample"            
               keyPass="sample"/>

Tuesday, October 8, 2013

Java - Setting server.xml on tomcat 7

@ on Server.xml

Java - Basic Authentication on Tomcat 7

@$ cd /usr/local/tomcat/conf
@Add the following this on the web.xml
<security-constraint>
        <web-resource-collection>
                <web-resource-name>
                        My Protected WebSite
                </web-resource-name>
                <url-pattern> /* </url-pattern>
                <http-method> GET </http-method>
                <http-method> POST </http-method>
        </web-resource-collection>
        <auth-constraint>
                <!-- the same like in your tomcat-users.conf file -->
                <role-name> aname </role-name>
        </auth-constraint>
</security-constraint>
<login-config>
        <auth-method> BASIC </auth-method>
        <realm-name>  Basic Authentication </realm-name>
</login-config>
<security-role>
        <description> aname role </description>
        <role-name> aname </role-name>
</security-role>
---------------------------------------------------------------------------------------
 @tomcat-users.xml
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <role rolename="aname" />

  <user username="tomcat" password="pwd" roles="manager-gui,admin-gui"/>
  <user username="aname" password="pwd" roles="aname"/>