[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl] SSL Demo still not working



Hi there,

to get things clear: the following code snippet is the code
I'm trying to excute to get a SSL connection to a https-URL.
It is derived from the SSLClient demo class.

--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

package demo;

import java.io.*;
import iaik.security.ssl.*;

public class MySSLClient {
  private SSLSocket socket;

  public MySSLClient() {
  }

  /** Establish the socket connection */
  public void connect( String host, int port ) throws IOException {
    SSLClientContext context = new SSLClientContext();
    socket = new SSLSocket(host, port, context);
    socket.startHandshake();
  }

  /** Send the HTTPS request */
  public void sendRequest() throws IOException {
    OutputStream out = socket.getOutputStream();
    InputStream  in  = socket.getInputStream();
    BufferedReader reader = new BufferedReader( new InputStreamReader(
in ) );
    out.write( "GET / HTTP/1.0".getBytes() );
    String line;
    while ( (line = reader.readLine()) != null )
      System.out.println(line);
  }

  public static void main(String arg[]) {
    try {
      MySSLClient client = new MySSLClient();
      client.connect( "www.iaik.at", 443 );
      client.sendRequest();
    } catch( Exception ex ) {
      System.out.println("An exception occured:");
      ex.printStackTrace();
    }
  }
}

--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

The result at runtime is the following exception:

An exception occured:
iaik.security.ssl.SSLException: Peer sent alert: Alert Fatal: handshake
failure
        at iaik.security.ssl.r.f(Unknown Source)
        at iaik.security.ssl.x.b(Unknown Source)
        at iaik.security.ssl.x.a(Unknown Source)
        at iaik.security.ssl.r.d(Unknown Source)
        at iaik.security.ssl.SSLTransport.startHandshake(Unknown Source)
        at iaik.security.ssl.SSLSocket.startHandshake(Unknown Source)
        at demo.MySSLClient.connect(MySSLClient.java:17)
        at demo.MySSLClient.main(MySSLClient.java:37)

That's it. Have fun trying to figure out what went wrong...

What's missing to me is sort of a "Programmer's Guide to the iSaSiLk".
I'm suspicious that the socket is being created using a default
SSLClientContext object. No ciphers, no root CA's no nothing.
Those defaults might be set by default like Sun and RSA do it in
their libs. But in comparison to those the result with the iSaSiLk
is quite frustrating...

Any comments are highly appreciated...

Marcus

--
  Marcus Olk
  m@rcus-olk.net

--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-ssl/sslthreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-ssl