Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Algorithm SunX509 not available on running sample HTTPs program

843811Feb 18 2005 — edited May 25 2005
import java.net.*;
import javax.net.*;
import javax.net.ssl.*;

public class ReadHttpsURL1 {
static final int HTTPS_PORT = 443;

public static void main(String argv[]) throws Exception {
if (argv.length != 1) {
System.out.println("Usage: java ReadHttpsURL1 ");
System.exit(0);
}

// Get a Socket factory
SocketFactory factory = SSLSocketFactory.getDefault();

// Get Socket from factory
Socket socket = factory.createSocket(argv[0], HTTPS_PORT);

BufferedWriter out = new BufferedWriter(new
OutputStreamWriter(socket.getOutputStream()));
BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
out.write("GET / HTTP/1.0\n\n");
out.flush();

String line;
StringBuffer sb = new StringBuffer();
while((line = in.readLine()) != null) {
sb.append(line);
}
out.close();
in.close();
System.out.println(sb.toString());
}
}

I get the following exception when I ran the class in Red Hat Linux ES 2.1

Exception in thread "main" java.net.SocketException: Default SSL context init failed: Algorithm SunX509 not available
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(DashoA6275)
at ReadHttpsURL1.main(ReadHttpsURL1.java:18)



I did not encounter any problems in compiling the file
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2005
Added on Feb 18 2005
3 comments
244 views