• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.net.SocketException: Default SSL context init failed: Algorithm SunX509 not avai  RSS feed

Hemal Mehta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody help. I get this error while running following program. I am using JDk1.4
package sslclient;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import javax.net.ssl.*;

import java.io.*;
import java.net.*;

import javax.security.cert.*;
// A simple text-based browser
public class voiceBrowser {
String urlString;
// You must supply the URL to be browsed
public static void main(String[] args) throws Exception {
voiceBrowser vBrowser = new voiceBrowser();
// Construct voice browser object
public voiceBrowser() {
// Get the URL
public void run() throws Exception {
String thisLine;
// Get a SocketFactory object for creating SSL sockets
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
// Create a secure socket connected to the HTTPS port (port 443) of a server
SSLSocket sslsock = (SSLSocket) factory.createSocket("", 443);
// Get the certificate presented by the web server. This may throw an
// exception if the server didn't supply a certificate. Look at the
// issuer of the certificate and decide if it is trusted.
SSLSession session = sslsock.getSession();
//Certificate cert = (Certificate)session.getPeerCertificateChain()[0];
//String issuer = cert.getIssuerDN().getName();
// Assuming we trust the certificate, we now use the socket just like a normal
// java.net.Socket object. So send a HTTP request and read the response
PrintWriter out = new PrintWriter(sslsock.getOutputStream());
out.print("GET " + "/homes/hmehta/web.xml" + " HTTP/1.0\r\n\r\n");
// Next, read the server's response and print it to the console.
BufferedReader in =
new BufferedReader(new InputStreamReader(sslsock.getInputStream()));
String line;
while((line = in.readLine()) != null) System.out.println(line);
// Finally, close the socket.


Peter den Haan
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we see a stack trace, and did you modify your JDK 1.4 setup in any way?
- Peter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!