简体   繁体   中英

SSL Handshake and Server Response

I want to know that if the website content change during SSL handshake or TCP handshake what happen?

For example:

The TCP or SSL handshake start exactly at 16:02:00 o'clock between the client and server.And some reason the handshake take a long time.Let's say 5 seconds.

So handshake finish at 16:02:05 with some latency but succesfully.And client start to the take content.

But if the site content change while ssl handshake.For example if it change at 16:02:03 what happen?

  • Let's say at 16:02:00 the site content is: "ABCD" (when ssl or tcp handshake start)

  • And at 16:02:03 it changes to: "ABCD1234"(while handshake continue)

So the client get which one of them; "ABCD" or "ABCD1234" ?

And here is the my client side java code for get the server response:

  Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
  URL obj = new URL(url); // url is https
  HttpURLConnection con = (HttpURLConnection) obj.openConnection(proxy);
  con.setConnectTimeout(10000);
  con.setReadTimeout(15000);

  int responseCode = con.getResponseCode();

  InputStream is =    con.getInputStream();

The server sends the response which is current at the time it opens the response file (or wherever it gets the response from). The full URL is only known after the server received the HTTP request. This request is only done after the SSL handshake inside the established SSL tunnel. Thus it will not serve the version from before the handshake.

Your code included in your post doesn't use clearly SSL, but with SSL, handshake must be done before anything else. No content will be downloaded before handshake is done (and valid) because no request can be done before that. Handskake must be finished to encode and decode correctly the request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM