Explorar o código

TLS 1.2 isn't enabled by default on older versions of Windows, so enable it ourselves. Also allows older TLS versions but not SSLv2.

Martijn Laan %!s(int64=5) %!d(string=hai) anos
pai
achega
1a770cd46b
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      Projects/Install.pas

+ 8 - 0
Projects/Install.pas

@@ -3491,6 +3491,12 @@ begin
     FAborted := True
     FAborted := True
 end;
 end;
 
 
+procedure SetSecureProtocols(const AHTTPClient: THTTPClient);
+begin
+  { TLS 1.2 isn't enabled by default on older versions of Windows }
+  AHTTPClient.SecureProtocols := [THTTPSecureProtocol.TLS1, THTTPSecureProtocol.TLS11, THTTPSecureProtocol.TLS12];
+end;
+
 function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String; const OnDownloadProgress: TOnDownloadProgress): Int64;
 function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String; const OnDownloadProgress: TOnDownloadProgress): Int64;
 var
 var
   DisableFsRedir: Boolean;
   DisableFsRedir: Boolean;
@@ -3540,6 +3546,7 @@ begin
     HTTPDataReceiver.OnDownloadProgress := OnDownloadProgress;
     HTTPDataReceiver.OnDownloadProgress := OnDownloadProgress;
 
 
     HTTPClient := THTTPClient.Create; { http://docwiki.embarcadero.com/RADStudio/Rio/en/Using_an_HTTP_Client }
     HTTPClient := THTTPClient.Create; { http://docwiki.embarcadero.com/RADStudio/Rio/en/Using_an_HTTP_Client }
+    SetSecureProtocols(HTTPClient);
     HTTPClient.OnReceiveData := HTTPDataReceiver.OnReceiveData;
     HTTPClient.OnReceiveData := HTTPDataReceiver.OnReceiveData;
 
 
     { Create temporary file }
     { Create temporary file }
@@ -3628,6 +3635,7 @@ begin
 
 
   HTTPClient := THTTPClient.Create;
   HTTPClient := THTTPClient.Create;
   try
   try
+    SetSecureProtocols(HTTPClient);
     HTTPResponse := HTTPClient.Head(Url);
     HTTPResponse := HTTPClient.Head(Url);
     if (HTTPResponse.StatusCode < 200) or (HTTPResponse.StatusCode > 299) then
     if (HTTPResponse.StatusCode < 200) or (HTTPResponse.StatusCode > 299) then
       raise Exception.CreateFmt('Getting size failed: %d %s', [HTTPResponse.StatusCode, HTTPResponse.StatusText])
       raise Exception.CreateFmt('Getting size failed: %d %s', [HTTPResponse.StatusCode, HTTPResponse.StatusText])