how to configure tls on Delphi TRestClient component

  

Helo,

I typed the code as follows and this code works well.
By using an https connection I hope that the Packet Data received cannot be read by applications such as Wireshark or the Packet Capture application on Android.

how do you configure the client side?

this my code

procedure TForm1.Button1Click(Sender: TObject);
var
MyCompletionHandler: TCompletionHandler;
MyErrorCompletionHandler: TCompletionHandlerWithError;
begin
ShowLoadingIndicator(Self, True);
Memo1.Lines.Clear;
RESTClient1.BaseURL := ‘https://reqres.in/’;
RESTClient1.RaiseExceptionOn500 := False;
RESTClient1.SecureProtocols := [THTTPSecureProtocol.TLS12];
RESTRequest1.ClearBody;
RESTRequest1.Resource := ‘api/users’;

MyCompletionHandler := procedure
var i: Integer;
tJson: TJSONValue;
begin
Label1.Text := ‘Complete!’;
Memo1.Lines.Append(‘Header: ‘);
for I := 0 to RESTResponse1.Headers.Count-1 do
Memo1.Lines.Append(RESTResponse1.Headers.Strings[I]);
Memo1.Lines.Append(”);
Memo1.Lines.Append(‘Body:’);
tJson := TJSONObject.ParseJSONValue(RESTResponse1.Content);
try
memo1.Lines.Append(REST.Json.TJson.Format(tJson));
finally
FreeAndNil(tJson);
end;
HideLoadingIndicator(Self);
end;

MyErrorCompletionHandler := procedure(AObject: TObject)
begin
Label1.Text := ‘Error!’;
HideLoadingIndicator(Self);
end;

RESTRequest1.ExecuteAsync(MyCompletionHandler, True, True, MyErrorCompletionHandler);
end;

result packet capture using
app

and this simple apps made with firemonkey:
Simple Apps

Comments are closed.