WinHTTP - The connection with the server was terminated abnormally

别来无恙 提交于 2021-02-10 18:52:54

问题


I import WinHTTP and try execute a request in a https url, like this:

function TForm1.GetPage(AURL: String): String; 
var 
  WinHttpRequest: IWinHTTPRequest; 
begin 
  CoInitialize(nil); 
  try 
    WinHttpRequest := CoWinHttpRequest.Create; 
    WinHttpRequest.Open('GET', AURL, False); 
    WinHttpRequest.Send(EmptyParam); 
    Result := WinHttpRequest.ResponseText; 
  finally 
    WinHTTPRequest := nil; 
    CoUninitialize; 
  end; 
end;

It works in same pages (ex: https://www.google.com), but not in others (ex: https://sourceforge.net), with error "The connection with the server was terminated abnormally".

Are there any additional settings I'm forgetting?

I'm using Delphi 2010.


回答1:


Most servers have migrated away from accepting SSL incoming traffic in favor of TLS protocol. Windows 7 and 8 do not have TLS protocol defined and hence VBA sendss traffic with SSL which is then blocked/dropped by such servers.

You will need to apply a 2-step patch/update to fix this for windows 7,

Step 1. Get Microsoft Update: Download relevant (32-bits or 64-bits of user's Windows version) Microsoft Security Protocol Update and install if not already install.

Step 2. Download Microsoft Easy Fix: Download Microsoft “Easy Fix” from Microsoft Support Article, and execute to set TLS 1.1+ as default.

Source : Update to enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows



来源:https://stackoverflow.com/questions/51844402/winhttp-the-connection-with-the-server-was-terminated-abnormally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!