I am using TNetHttpRequest and TNetHTTPClient to send post data to API url like this:
Params := TMultiPartFormData.Create;
Params.AddFile('file_upload', 'c:\myfile.txt','application/octet-stream');
NetHTTPRequest1.Post('https://myurl.com', Params);
This work fin on Windows 10 but on new Windows 7 Home edition I get error
Error Sending data (12175) A security error occurred
I looked at Microsoft error number HERE
ERROR_WINHTTP_SECURE_FAILURE
12175
One or more errors were found in the Secure Sockets Layer (SSL) certificate sent by the server. To determine what type of error was
encountered, check for a WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
notification in a status callback function. For more information, see
WINHTTP_STATUS_CALLBACK.
But I really dont know how to call these callback fundtions or what is causing this error ?
asked Apr 11, 2019 at 22:37
2
I solved this by unchecked using SSL2
and SSL3
from NetHTTPClient1
and I used only TLS
answered Apr 11, 2019 at 23:12
zaczac
4,50715 gold badges63 silver badges127 bronze badges
2
I had experienced the same error on Windows 7 Pro, reproducible easily by using the Delphi 10.3. Sample «HttpAsyncDownload».
I tested the compiled application on Windows 10 where it runs flawlessly.
Finally, I found following page which solved the issue for me:
https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi
Briefly, support for Transport Layer Security (TLS) 1.1 and TLS 1.2 is acitvated for Windows 7. I used the «easy fix», which enables this systemwide as well as for Internet explorer.
Finally, the above sample application «HttpAsyncDownload» runs on Windows 7 Pro flawlessly.
answered Aug 2, 2020 at 11:20
I am using TNetHttpRequest and TNetHTTPClient to send post data to API url like this:
Params := TMultiPartFormData.Create;
Params.AddFile('file_upload', 'c:\myfile.txt','application/octet-stream');
NetHTTPRequest1.Post('https://myurl.com', Params);
This work fin on Windows 10 but on new Windows 7 Home edition I get error
Error Sending data (12175) A security error occurred
I looked at Microsoft error number HERE
ERROR_WINHTTP_SECURE_FAILURE
12175
One or more errors were found in the Secure Sockets Layer (SSL) certificate sent by the server. To determine what type of error was
encountered, check for a WINHTTP_CALLBACK_STATUS_SECURE_FAILURE
notification in a status callback function. For more information, see
WINHTTP_STATUS_CALLBACK.
But I really dont know how to call these callback fundtions or what is causing this error ?
asked Apr 11, 2019 at 22:37
2
I solved this by unchecked using SSL2
and SSL3
from NetHTTPClient1
and I used only TLS
answered Apr 11, 2019 at 23:12
zaczac
4,50715 gold badges63 silver badges127 bronze badges
2
I had experienced the same error on Windows 7 Pro, reproducible easily by using the Delphi 10.3. Sample «HttpAsyncDownload».
I tested the compiled application on Windows 10 where it runs flawlessly.
Finally, I found following page which solved the issue for me:
https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi
Briefly, support for Transport Layer Security (TLS) 1.1 and TLS 1.2 is acitvated for Windows 7. I used the «easy fix», which enables this systemwide as well as for Internet explorer.
Finally, the above sample application «HttpAsyncDownload» runs on Windows 7 Pro flawlessly.
answered Aug 2, 2020 at 11:20
Skip to content
This is a Windows 7 error, this update can fix the problem. But we can solve the problem without requiring the update using the code below.
SSL2 must be disabled. SSL3,TLS1,TLS11,TLS12 can be used.
SOLUTION:
uses REST.Types, REST.Client, REST.Authenticator.Basic, Data.Bind.Components, Data.Bind.ObjectScope, NetEncoding, System.Net.HttpClient; begin RESTClient1 := TRESTClient.Create('https://test.com/api'); try RESTClient1.SecureProtocols := [THTTPSecureProtocol.SSL3,THTTPSecureProtocol.TLS1,THTTPSecureProtocol.TLS11,THTTPSecureProtocol.TLS12]; HTTPBasicAuthenticator1 := THTTPBasicAuthenticator.Create('apikey',MyApiKey); try RESTRequest1 := TRESTRequest.Create(nil); try RESTRequest1.Method := TRESTRequestMethod.rmPOST; RESTClient1.Authenticator:=HTTPBasicAuthenticator1; RESTRequest1.Client := RESTClient1; RESTRequest1.ClearBody; RESTRequest1.AddBody('{"input1": ["abc"], "input2":"xyz"}',TRestContentType.ctAPPLICATION_JSON); RESTRequest1.Execute; MyResult := RESTRequest1.Response.Content; finally RESTRequest1.Free; end; finally HTTPBasicAuthenticator1.Free; end; finally RESTClient1.Free; end; end;
I have run into the same problem with the RESTClient (and any HTTPS based controls for that matter), and i suspect the issue you are having with windows 7, is due to the limited cipher suites available on 7 and 8.1
Some servers have switched to using strong cipher’s for their TLS…and merely enabling TLS 1.2 will not work on operating systems older than Windows 10.
I’ve seen some servers only support TLS ciphers such as
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
These are not supported on Windows 7 (and i believe neither on 8.1) — there is no way to add them either.
Microsoft in their (lack) of wisdom never added them on their final cipher update, despite them being in use at the time, and now these OS’s no longer receive any mainstream support and are considered EOL, they won’t ever add them.
If you try to connect to a server which uses the above ciphers for TLS, on windows 7, you will get the 12175 security error.
You can see what ciphers are supported on windows 7 here: https://docs.microsoft.com/en-us/windows/win32/secauthn/tls-cipher-suites-in-windows-7
You can test your servers SSL certificate here to find out what TLS ciphers it supports: https://www.ssllabs.com/ssltest
If the server supports ciphers on the list, and yet you are still getting the error then the previous posts for enabling TLS1.2 on windows 7 may work, you may also have to set the appropriate SecureProtocols property on the RESTClient.
httpCli := TNetHTTPClient.Create(nil);
// httpCli.OnReceiveData := nil;
if (basicAuthUser <> ») and (basicAuthPw <> ») then
begin
var LCredentials := TCredentialsStorage.TCredential.Create
(TAuthTargetType.Server, », url, », »);
LCredentials.Username := basicAuthUser;
LCredentials.Password := basicAuthPw;
httpCli.CredentialsStorage.AddCredential(LCredentials);
httpCli.UseDefaultCredentials := false;
end;
httpCli.SendTimeout := sendTimeout;
httpCli.ResponseTimeout := readTimeout;
httpCli.ConnectionTimeout := connTimeOut;
httpCli.ContentType := ContentType;
httpCli.AcceptCharSet := AcceptCharSet;
httpCli.Accept := ‘application/json’;
{$IFNDEF ANDROID}
// httpCli.SecureProtocols :=
// [THTTPSecureProtocol.SSL2,THTTPSecureProtocol.SSL3,THTTPSecureProtocol.TLS1,THTTPSecureProtocol.TLS11,THTTPSecureProtocol.TLS12,THTTPSecureProtocol.TLS13];
httpCli.SecureProtocols :=
[THTTPSecureProtocol.SSL3,THTTPSecureProtocol.TLS1,THTTPSecureProtocol.TLS11,THTTPSecureProtocol.TLS12,THTTPSecureProtocol.TLS13];
{$ENDIF}
{$IFNDEF MACOS}
if assigned(OnReceiveData) then
httpCli.OnReceiveData := OnReceiveData;
{$ENDIF}
result := httpCli.Get(url,nil,xtHeaders);