Hello,
I have a problem with a Win32 application using Indy. All of a sudden it throws me the following error message:
"Error connecting with SSL. error 1409442E:SSL routine:ssl3_read_bytes:tlsv1 alert protocol version"
In the beginning, I supposed it had something to do with an obsolete version I manage in my source.
The following is the only place in my source where I set the SSL version and it supports the version 1.2
function TConnectionClass.GetToken: Boolean;
var
LJSONObject: TJSONObject;
LJSONValue: TJSONValue;
{$IFDEF VER230}
LJSONPair: TJSONPair;
{$ENDIF}
LJSONToken: TJSONValue;
IdHTTP: TIdHTTP;
IdSSL: TIdSSLIOHandlerSocketOpenSSL;
IdLogFile: TIdLogFile;
sList: TStringList;
begin
Result := False;
FToken := '';
IdHTTP := TIdHTTP.Create(nil);
try
IdHTTP.HTTPOptions := IdHTTP.HTTPOptions + [hoForceEncodeParams];
IdHTTP.HandleRedirects := True;
IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP);
IdSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
IdHTTP.IOHandler := IdSSL;
IdLogFile := TIdLogFile.Create(IdHTTP);
IdLogFile.Filename := 'c:\' + ChangeFileExt(ExtractFileName(ParamStr(0)), '.log');
IdLogFile.Active := True;
IdHTTP.Intercept := IdLogFile;
IdHTTP.Request.Accept := 'application/json';
IdHTTP.Request.CustomHeaders.Values['X-Application'] := cBetfair_AppKey;
IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
sList := TStringList.Create;
try
sList.Add('username=' + FUserID);
sList.Add('password=' + FPassword);
LJSONValue := TJSONObject.ParseJSONValue(IdHTTP.Post(URL_LOGIN, sList));
try
if LJSONValue is TJSONObject then
begin
LJSONObject := TJSONObject(LJSONValue);
{$IFDEF VER230}
LJSONPair := LJSONObject.Get('token');
if LJSONPair <> nil then
LJSONToken := LJSONPair.JsonValue
else
LJSONToken := nil;
{$ELSE}
LJSONToken := LJSONObject.Values['token'];
{$ENDIF}
if LJSONToken <> nil then
FToken := LJSONToken.Value;
end;
finally
LJSONValue.Free;
end;
finally
sList.Free;
end;
finally
IdHTTP.Free;
end;
Result := (FToken <> '');
end;
I also tried to amend the options into
IdSSL.SSLOptions.SSLVersions := [sslvTLSv1_2];
but the error is still the same
Then I updated the SSL .dll files in my system32 folder by downloading the latest version of libeay32.dll and ssleay32.dll from here https://indy.fulgan.com/SSL/ and replace the old files with the new ones.
I have double-checked and now the .dll have Version file 1.0.2.21 and Version 1.0.2u
Despite these attempts, the application still throws me the same exception.
Is there anything else I should change?
Many thanks
Alberto