按常规配置方式 在 server.xml里添加如下 配置 :
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="conf/cnzz.freeca.cn.jks" keystorePass="123"
clientAuth="false" sslProtocol="TLS" />
启动 Tomcat 7,会发现443端口无法正式启动下面是启动日志:
2011-12-29 10:10:49 Commons Daemon procrun stderr initialized
2011-12-29 10:10:50 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.20.
2011-12-29 10:10:50 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2011-12-29 10:10:52 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-80"]
2011-12-29 10:10:52 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
2011-12-29 10:10:52 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-443"]
2011-12-29 10:10:52 org.apache.coyote.AbstractProtocol init
严重: Failed to initialize end point associated with ProtocolHandler ["http-apr-443"]
java.lang.Exception: Connector attribute SSLCertificateFile must be defined when using SSL with APR
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:469)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:490)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:364)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:910)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:101)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:101)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:781)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:101)
at org.apache.catalina.startup.Catalina.load(Catalina.java:572)
at org.apache.catalina.startup.Catalina.load(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:262)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)
2011-12-29 10:10:52 org.apache.catalina.core.StandardService initInternal
严重: Failed to initialize connector [Connector[HTTP/1.1-443]]
org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:912)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:101)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:101)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:781)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:101)
at org.apache.catalina.startup.Catalina.load(Catalina.java:572)
at org.apache.catalina.startup.Catalina.load(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:262)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)
Caused by: java.lang.Exception: Connector attribute SSLCertificateFile must be defined when using SSL with APR
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:469)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:490)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:364)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:910)
... 13 more
2011-12-29 10:10:52 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 2268 ms
2011-12-29 10:10:52 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
分析:
方法:
在 Tomcat 中注释掉 下面的配置:
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
重新启动 Tomcat ,443已经能正常启动,再看下日志:
2011-12-29 10:30:14 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-80"]
2011-12-29 10:30:14 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
2011-12-29 10:30:14 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-443"]
2011-12-29 10:30:14 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1300 ms
2011-12-29 10:30:14 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
2011-12-29 10:30:14 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.16