SSL Socket Programming.

Hi guy's , im currently on socket programming here.

Im trying to read the content of an https page with an applet. So im writing the socket , and everything work fine the first time im running the applet, but when im trying to reload the page , after few try ( never the same number of try ) ive got an SSLException :

FATAL ERROR BAD_RECORD_MAC

But when im trying to do the same code localy on my machine , not in an applet , ive got no problems reading the page.

Did someone know if java 6.0 have problems with applet and socket matches ?

Here my code :

try

{

String urlString ="https://www.monsite.com/index.html";

URL url =new URL(urlString);

SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();

SSLSocket socket = (SSLSocket)factory.createSocket(url.getHost(), 443);

PrintWriter out =new PrintWriter(new OutputStreamWriter( socket.getOutputStream()));

out.println("GET /index.html HTTP/1.1\r");

out.println("Host:monsite.com \r\n\r");

out.println();

out.flush();

BufferedReader in =new BufferedReader(

new InputStreamReader(

socket.getInputStream()));

String line;

while ((line = in.readLine()) !=null){

System.out.println(line);

}

out.close();

in.close();

}

catch(Exception e)

{

System.out.println("in the exception :"+e.getMessage());

}

Please , help me , ive got no idea what to do with that.

sorry for my english , im from quebec so its why ive got probably a lot of mistake ;)

[2171 byte] By [JavaChrisa] at [2007-11-27 11:58:30]
# 1

Could it be because the client is closing the connecion to the server before it sends all the buffer?

I mean, when reloading the page do you wait for the page to load or intead you keep reloading the page?

MeTItus

Me_Titusa at 2007-7-29 19:20:02 > top of Java-index,Java Essentials,Java Programming...
# 2

It appears that the connection's other end has a problem:

bad_record_mac

This alert is returned if a record is received with an incorrect MAC. This message is always fatal.

ChuckBinga at 2007-7-29 19:20:02 > top of Java-index,Java Essentials,Java Programming...
# 3

I understand that it is always fatal but why does it keeps happening when the applet is reloaded several times?

vincent.saulniera at 2007-7-29 19:20:02 > top of Java-index,Java Essentials,Java Programming...
# 4

> I understand that it is always fatal but why does it

> keeps happening when the applet is reloaded several

> times?

I don't know.

I wonder if it is because the site is French. See this bug report (there is a workaround listed there) and see if it helps.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4513263

cotton.ma at 2007-7-29 19:20:02 > top of Java-index,Java Essentials,Java Programming...