Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / December 2003

Tip: Looking for answers? Try searching our database.

Need help getting HttpsURLConnection to work

Thread view: 
John - 03 Dec 2003 19:53 GMT
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 that anyone could provide.

I have a simple servlet running in Tomcat that does nothing more than
report back that it is 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 client machine.

2.    If I do nothing other than the change the HttpURLConnection to an
HttpsURLConnection then everything falls apart immediately and I don't
understand why. 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 to print
"null" 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. Again,
any help would be greatly appreciated.

BTW:     I am using Java v 1.4.2_02-b03
    Tomcat v 4.1.29

-- Thanks in advance!
John - 04 Dec 2003 21:34 GMT
Got the answer to my problem here from another group. Will post it in
case anyone else is having the same trouble and wants to know how to
fix it...
--------------------------------------------

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.

Mike

--------------------------------------------
> I'm having trouble getting an HttpsURLConnection to work as expected.
> I suspect I am missing something (possibly a great many things) and
[quoted text clipped - 36 lines]
>
> -- Thanks in advance!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.