简体   繁体   中英

Secure connection in localhost tomcat not working

I am working on spring web app using maven. I am trying to make localhost a secure connection.I am using tomcat server. I used this link for creating my own CA and added it to JVM. This is what I added in pom.xml.

<plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <path>/security</path>
            <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true" maxThreads="200" scheme="https" secure="true" keystoreFile="/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64/jre/lib/security/cacerts.jks" keystorePass="security"
           clientAuth="false" sslProtocol="TLS" />

        </configuration>
</plugin>

I went to the link: https://localhost:8443 . But no app is running on that port. Could someone please help?

Go to sever.xml and add following xml

 <Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" 
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 
clientAuth="false" sslProtocol="TLS" keystoreFile="{path}/mycer.cert" keystorePass="{password}"/>
     <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
  1. first you want to create one CA certificate
  2. you can use java key tool for certificate creation
  3. store that certificate on your server .
  4. add connector config with in your tomcat server.xml
  5. you should provide certificate path and password that given
  6. restart server

if any problem for restarting comment stack trace

http://www.mkyong.com/tomcat/how-to-configure-tomcat-to-support-ssl-or-https/

You need to add a connector in servlet.xml file.

<Connector
           protocol="org.apache.coyote.http11.Http11Protocol"
           port="8443" maxThreads="200"
           scheme="https" secure="true" SSLEnabled="true"
           keystoreFile="${user.home}/.keystore" keystorePass="changeit"
           clientAuth="false" sslProtocol="TLS"/>

Replace the keystore file path and the password with the ones you have.

Refer https://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM