在tomcat 7.0中发出问题以配置tomcat以支持ssl

use*_*218 6 ssl tomcat

为了支持tomcat中的ssl ....我创建了一个Keystore文件.包含自签名证书.....然后打开tomcat 7.0的server.xml文件并在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 port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" /> -->    ` 
Run Code Online (Sandbox Code Playgroud)

并从连接器中删除注释,并将KeystoreFile条目和KeystorePass条目放在未注释的连接器代码中,如下所示.........

`    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
      maxThreads="150" scheme="https" secure="true"
      clientAuth="false" sslProtocol="TLS" **keystoreFile**="d:\cpademo.keystore"
     **keystorePass**="cpademo"/>      `

The above code works in tomcat 6.0...and allow https connection with tomcat but i get the error in tomcat 7.0 log file which indicate that it does not suppoert connection to https 8443 connection. Error in log file is following as.....

ERROR:

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-ap
r-8443"]
java.lang.Exception: Connector attribute SSLCertificateFile must be defined when
using SSL with APR
    at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:484)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:554)
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题.Thanx提前

Mar*_*mas 17

您正在使用APR /本机连接器以及JSSE连接器(BIO和NIO)的SSL配置.最简单的解决方法是在server.xml中注释掉APR生命周期监听器.


Den*_*isS 9

你必须改变protocol

protocol="HTTP/1.1"
Run Code Online (Sandbox Code Playgroud)

protocol="org.apache.coyote.http11.Http11NioProtocol"
Run Code Online (Sandbox Code Playgroud)

这是一篇很好的文章 http://java.dzone.com/articles/setting-ssl-tomcat-5-minutes

mkyong的文章已经过时,缺乏我上面提出的改变.