简体   繁体   English

SSL握手和服务器响应

[英]SSL Handshake and Server Response

I want to know that if the website content change during SSL handshake or TCP handshake what happen? 我想知道,如果网站内容在SSL握手或TCP握手期间发生更改,会发生什么情况?

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. TCP或SSL握手恰好在客户端和服务器之间的16:02:00开始,并且由于某种原因握手需要花费很长时间,例如5秒钟。

So handshake finish at 16:02:05 with some latency but succesfully.And client start to the take content. 因此握手在16:02:05处完成,但有一定延迟,但成功完成了,客户端开始获取内容。

But if the site content change while ssl handshake.For example if it change at 16:02:03 what happen? 但是,如果网站内容在ssl握手时发生更改,例如在16:02:03发生更改,会发生什么?

  • Let's say at 16:02:00 the site content is: "ABCD" (when ssl or tcp handshake start) 假设在16:02:00,网站内容为:“ ABCD”(当ssl或tcp握手启动时)

  • And at 16:02:03 it changes to: "ABCD1234"(while handshake continue) 并在16:02:03更改为:“ ABCD1234”(同时继续握手)

So the client get which one of them; 这样客户就可以得到其中一个。 "ABCD" or "ABCD1234" ? “ ABCD”还是“ ABCD1234”?

And here is the my client side java code for get the server response: 这是我的客户端Java代码,用于获取服务器响应:

  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. 只有在服务器收到HTTP请求后,才能知道完整的URL。 This request is only done after the SSL handshake inside the established SSL tunnel. 仅在已建立的SSL隧道内的SSL握手之后才执行此请求。 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. 您帖子中包含的代码并未明确使用SSL,但是对于SSL,必须先进行握手。 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. 必须完成握手才能正确编码和解码请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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