Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 46886 invoked from network); 4 Dec 2003 14:19:04 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Dec 2003 14:19:04 -0000 Received: (qmail 65533 invoked by uid 500); 4 Dec 2003 14:18:41 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 65516 invoked by uid 500); 4 Dec 2003 14:18:40 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 65503 invoked from network); 4 Dec 2003 14:18:40 -0000 Received: from unknown (HELO rwcrmhc13.comcast.net) (204.127.198.39) by daedalus.apache.org with SMTP; 4 Dec 2003 14:18:40 -0000 Received: from mikeslaptop (ip-64-32-193-230.dsl.iad.megapath.net[64.32.193.230]) by comcast.net (rwcrmhc13) with SMTP id <2003120414184101500bdb07e> (Authid: mkellstrand); Thu, 4 Dec 2003 14:18:42 +0000 Message-ID: <07ca01c3ba71$85538560$680fa8c0@MikesLaptop> From: "Mike Kellstrand" To: "Tomcat Users List" Cc: References: <200312031836.hB3Ia5Y15767@adelie.iim.com> <06f401c3b9e6$112ffc80$680fa8c0@MikesLaptop> Subject: Re: Need Help getting SSL to work with HttpsURLConnections Date: Thu, 4 Dec 2003 09:18:41 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 x-mimeole: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N John, I found a solution. Add the line below to force it to use the correct libraries: System.setProperty("java.protocol.handler.pkgs","javax.net.ssl"); This one falls into the inexplicable category of problems that lots of people must have dealt with, yet Google shows up almost nothing, and you never get a reply about it in the mail-group. cranky this morning, Mike ----- Original Message ----- From: "Mike Kellstrand" To: "Tomcat Users List" Sent: Wednesday, December 03, 2003 4:40 PM Subject: Re: Need Help getting SSL to work with HttpsURLConnections > I just came across a similar problem today. > > I have working code in a Swing app that uses import javax.net.ssl.*; > > I copied the ssl connection code over to another app > that happens to be a servlet, and I get the ClassCastException as seen > below, > at the line of code: > connection = (HttpsURLConnection) url.openConnection(); > > Anybody know what is going on? > > Thanks, Mike > > > ----- Original Message ----- > From: "John Kammer" > To: "Tomcat Users List" > Sent: Wednesday, December 03, 2003 4:02 PM > Subject: Re: Need Help getting SSL to work with HttpsURLConnections > > > > An update.... and a correction... > > > > I was able to get the HttpsURLConnection to work by replacing: > > > > import javax.net.ssl.*; > > > > with: > > > > import com.sun.net.ssl.*; > > > > Contrary to what I had said below there is an java.lang.ClassCastException > being thrown when making the call : > > HttpsURLConnection conn = (HttpsURLConnection) myurl.openConnection(); > > > > Now the compiler warns me that I'm using deprecated code, but it does > work. > > Still, why would javax.net.ssl.* be having this problem ? > > > > Thanks again! > > > > > > ----------------------------------------------------------- > > > Forgive me, I'm new at this... > > > > > > I am using: Java v 1.4.2_02-b03 > > > : Tomcat v 4.1.29 > > > > > > I'm having trouble getting an HttpsURLConnection to work as expected. I > suspect I am missing something (possibly a great many things) and would > appreciate any insight anyone could provide. I've not been able to find a > single source that addresses this problem although I've found bits and > pieces in several places. > > > > > > I have a simple servlet running in Tomcat that does nothing more than > report back that it is alive. Posting to it at > http://myserver:8080/simpleServlet/simpleServlet returns a response of: > > > > > > I am alive!. > > > > > > Additionally I have a simple client app that calls the servlet with a > POST. The client can run on either the same machine as the server or a > different machine. > > > > > > 1. Using an HttpURLConnection in the client app works fine. I can call > the servlet on either port 8080 (http) or 8443 (https). This works from > either machine. > > > > > > 2. If I do nothing other than change the HttpURLConnection to an > HttpsURLConnection then everything falls apart immediately and I don't > understand why (I do believe I have the proper imports included and it all > compiles fine). From everything I can tell I should be able to replace the > one with the other. > > > > > > 3. Keystores & certificates: I have generated certificates for both > machines using keytool and have imported the client machine certificate into > the trustedcerts file on the server machine. I have NOT had any of these > certificates signed by a certificate authority (and due to complexities I > won't go into here that isn't likely to happen). Do the certificates need > to be signed by a CA in order for HttpsURLConnection to work? > > > > > > 4. The result of calling the method url.openConnection() is that "null" > is printed to the screen then program execution simply stops. No Exception > seems to be thrown - everything just stops. Why? > > > > > > HttpsURLConnection conn = (HttpsURLConnection) myurl.openConnection(); > > > > > > Ultimately I would like to get Client-Certification working but haven't > been able to find a good guide out there for doing so. At the moment I am > taking small steps in the hope of gaining a better understanding. Any help > would be greatly appreciated. > > > > > > Thanks in advance ! > > > -- John Kammer > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org