You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kirby Vandivort <kv...@ks.uiuc.edu> on 2001/12/05 22:13:51 UTC

problems accessing https URLs from a servlet

Ignacio asked me to send a test message to see if my account had
access, so I figured I'd throw a real question in at the same time..
:)


I am trying to access https URLs from within a tomcat servlet and am
not having any luck.

I am using tomcat 4.0.1, jsse 1.0.2, java 1.3..  That's the important
version numbers I can think of..

I am NOT trying to access tomcat via https.  I am trying to make a URL
connection from a servlet to a https URL.

I have recently started using Tomcat and was previously using JServ.
The exact same code worked beautifully under JServ.  When I switched to
tomcat it quit working.

Some debugging help...

My code that adds the handlers reads:

// set ourselves up to handle ssl
java.security.Security.addProvider(
                                 new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("java.protocol.handler.pkgs",
                              "com.sun.net.ssl.internal.www.protocol");

I am putting the 3 jsse jar files in the lib directory under 
webapps/...../WEB-INF.

It fails by telling me that I have a malformed URL when I try to create
a URL object with a https prefix.

(something like:   new URL("https://blah.com")

IF I remove the 3 jar files I start getting class not found exceptions,
so it is finding the jar files.

IF I run with the java 1.4 beta it works.  So it is something about having
to manually insert jsse.

IF I set the JSSE_HOME variable (which causes the jar files to be put in
the classpath for tomcat itself) I get past the malformed URL lines.  I
then start getting 

java.net.SocketException: SSL implementation not available
        at javax.net.ssl.DefaultSSLSocketFactory.createSocket([DashoPro-V1.2-120
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect([Da
        at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer(
        at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l([DashoPro-V1
        at com.sun.net.ssl.internal.www.protocol.https.HttpClient.<init>([DashoP
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<init>([Dasho
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
        at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
        at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connec
        at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getOut
        at TB.collab.db.EventServerConnection.makeConnection(EventServerConnecti  
this exception.  Which tells me again that I think I'm getting some
sort of collision between the code that tomcat has set up to allow
accesses via https and what I'm doing.

If I set JSSE_HOME and have the jsse debugging turned on, I sometimes
get:

default context init failed: 
   java.security.PrivilegedActionException 
   <<java.security.NoSuchAlgorithmException: 
     Class com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl 
     configured for KeyManagerFactory not a KeyManagerFactory>>    


Let's see.. what else have I tried..  This happens to be on redhat 7.2,
though I don't think that makes a difference.

It doesn't seem to make a difference if I put the jsse jar files in
$JAVA_HOME/lib/ext.


I'm at a loss.  The code worked well under jserv (and still works if I
run it using JServ); it doesn't work under tomcat.  

Question about the tomcat code..  Is it adding security providers via
java.security.Security.addProvider()?  I'm wondering if maybe my code
for creating a new URL object is calling upon the wrong security
provider..

Any help would be appreciated.

Thanks,

-- 

Kirby Vandivort                      Theoretical Biophysics Group
Email: kvandivo@ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>