Problem with JSSE and Resin:

I'm using Java Secure Socket Extension (JSSE) 1.0.1

http://java.sun.com/products/jsse/

Operating system: Windows 2000
Web Server/Servlet engine: Apache/Resin
JDK version: jdk1.2.2

Basically all JSSE boils down to is placing three jar files in your
classpath:

<classpath id='c:/resin1.1/lib/jcert.jar'/>
<classpath id='c:/resin1.1/lib/jnet.jar'/>
<classpath id='c:/resin1.1/lib/jsse.jar'/>

importing java.security.* and executing the following line:

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

This allows the following to work:

SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket)factory.createSocket("www.verisign.com", 443);

Once you have an SSLSocket you can do any kind of SSL communication you
want.  The trouble is I'm getting:

java.net.SocketException: SSL implementation not available

when it tries to create the SSLSocket!  Here's the really weird part.  It
works perfectly when I run it from the command line.  If I open a dos window
and run the program with java MyProgramName it connects to verisign on port
443 no problem.  But, if I execute the SAME CODE from within a servlet I get
that SSL implemention not available error.

I'm pretty sure it has something to do with the Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider()); line.

The docs to JSSE tell you to modify the file:

JAVA_HOME/jre/lib/security/java.security

with the following:

#
# List of providers and their preference orders (see above):
#
security.provider.1=sun.security.provider.Sun
security.provider.2=com.sun.net.ssl.internal.ssl.Provider

is it possible that resin has no idea this file exists?  I set my path to
use the java.exe from the JAVA_HOME/jre/bin directory.  Why is there an SSL
Implemention available when the code is run from the command line, but not
from the servlet?

I tried calling Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider()); in many places in the code before
I try and create the socket, but no luck.

Any ideas?

-Andrew

........................................................
iWon $10 million Giveaway TV show - April 15th on CBS
iWon.com       http://www.iwon.com    why wouldn't you?
........................................................

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to