Solved

using URLHttpsConnection

Posted on 2001-08-14
8
449 Views
Last Modified: 2013-11-24
Hi

where can I find source codes to do SSL session for servlets  using URLHttpsConnection.

Presently I am using URLHttpConnection to access and return data in a servlet.


How can I get it SSL enabled.
0
Comment
Question by:TLTEO
  • 4
  • 3
8 Comments
 

Expert Comment

by:phlc
ID: 6385489
0
 
LVL 92

Expert Comment

by:objects
ID: 6387039
Grab JSSE from Sun it supports SSL:
http://java.sun.com/products/jsse/
0
 

Author Comment

by:TLTEO
ID: 6389039
they don't have the examples really, on URLHttpsConnection.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 92

Expert Comment

by:objects
ID: 6390608
If your using JSSE then it's all transparent. You just specify the (https) url you require and use URLConnection the same as you would for standard http.

URL secure = new URL("https://tlteo.com/my.html");
URLConnection conn = secure.openConnection();
...
0
 

Author Comment

by:TLTEO
ID: 6393931
yeap i know,, but I am using apache with tomcat, and I dont use mod_ssl.  I am trying to use jsse to create a SSL session.

Seems like the crucial part is the PrintWriter out PrintWriter out;
     
            res.setContentType("text/html");
            out = res.getWriter();

How can I link
 
socket.startHandshake();
         PrintWriter out = new PrintWriter(
                      new BufferedWriter(
                      new OutputStreamWriter(
                           socket.getOutputStream())));

         SSLSocket socket =
          (SSLSocket)factory.createSocket(tunnel, host, port, true);



         

0
 
LVL 92

Expert Comment

by:objects
ID: 6394895
Are you trying to write SSL?
Sorry I thought you were trying to read SSL.
0
 
LVL 92

Accepted Solution

by:
objects earned 30 total points
ID: 6394905
0
 

Author Comment

by:TLTEO
ID: 6418675
it is tuff writing this using URLHttpsConnection.  But anyway, I am trying to install a self signed cert into the system and test it.  more problems to come . Cheers
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question