• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
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();

}

}
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we see a stack trace, and did you modify your JDK 1.4 setup in any way?
- Peter
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic