aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes java.net.SocketException: Default SSL context init failed: Algorithm SunX509 not avai Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.net.SocketException: Default SSL context init failed: Algorithm SunX509 not avai" Watch "java.net.SocketException: Default SSL context init failed: Algorithm SunX509 not avai" New topic
Author

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

Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101
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();
vBrowser.run();
}
// 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("113.128.2.131", 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");
out.flush();
// 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.
sslsock.close();

}

}
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Can we see a stack trace, and did you modify your JDK 1.4 setup in any way?
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.SocketException: Default SSL context init failed: Algorithm SunX509 not avai