Re: If you want to access a secure (HTTPS) website and...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Selina_Duman
Posted On:   Wednesday, March 21, 2001 06:32 AM

Hi, I want to create an SSL Socket connection from a Java application which is into client side. I didn't run below code part. SSLsocket is created but I asume that I can't write to socket anything and in addition to this I can't read anything. For this What can I do? Have I need client-side certificate? Regards. import javax.net.ssl.*; import java.io.*; import java.net.*; import java.security.*; public class SSLSocketClient { public static void main(String args[]) throws Exception { String urlString = (args.length == 1) ? args[0] : "http://www.verisign.com/index.html"; URL url = new URL(urlString); Security.addProvider(    More>>

Hi,
I want to create an SSL Socket connection from a Java application which is into client side. I didn't run below code part. SSLsocket is created but I asume that I can't write to socket anything and in addition to this I can't read anything.
For this What can I do? Have I need client-side certificate?
Regards.

import javax.net.ssl.*;
import java.io.*;
import java.net.*;
import java.security.*;

public class SSLSocketClient {

public static void main(String args[]) throws Exception {

String urlString = (args.length == 1) ?
args[0] : "http://www.verisign.com/index.html";
URL url = new URL(urlString);

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

SSLSocketFactory factory =
(SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket =
(SSLSocket)factory.createSocket(url.getHost(), 443);

PrintWriter out = new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream()));
out.println("GET " + urlString + " HTTP/1.1");
out.println();
out.flush();

BufferedReader in = new BufferedReader(
new InputStreamReader(
socket.getInputStream()));

String line;

while ((line = in.readLine()) != null) {
System.out.println(line);
}

out.close();
in.close();
}
}

   <<Less

If you want to access a secure (HTTPS) website and...

Posted By:   Sridharan_kuppa  
Posted On:   Monday, April 30, 2001 11:58 AM

Hi,
Have you installed trustCertificate?
You are trying to connect with verisign site. The verisign trustcertificate comes with "samplecacert". copy your samplecacert into your {user.home}/lib/seccurity directory and change the file name into cacert. Now run your program again. It will work.


....
Sridharan
About | Sitemap | Contact