You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by tam wei <tw...@gmail.com> on 2005/07/22 08:54:09 UTC

tomcat SSL problem

Hi all,

I am trying to open a SSL connection from a tomcat server (called it TC1) 
that locate within a DMZ to the other tomcat server (called it TC2) which is 
located in external network.

I got the following in the TC1 system.out,

WARNING: Servlet.service() for servlet HelloWorld threw exception
java.net.SocketException: Default SSL context init failed: null
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Sou
rce)
at HelloWorld.doGet(HelloWorld.java:20)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Unknown Source)

Here is the servlet i place in TC1 which open a SSL connection to TC2.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.URL;
import java.net.URLConnection;

public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response) 
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");

URL url = new URL("https://154.123.23.10:8443");
URLConnection con = url.openConnection(); 
con.connect();

}
}

 I have used java keytool to generate a self-signed cert and also a keystore 
in TC2. Below is the Connector element of the server.xml of TC2

<Connector port="8443" 
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" 
keystoreFile="C:\program files\Tomcat 5.5.7\keystore\.keystore"/>

I also imported the self-signed cert into the truststore of machine which 
host the TC1. The place i store the self-signed cert of TC2 is 
jre_home\lib\security\cacerts

I think i have setup the SSL correctly.

Does anyone know how to resolve the exception "java.net.SocketException: 
Default SSL context init failed: null" I mentioned above?

Thanks for your help

wx