4

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

mgk
  • 71
  • 5
  • What is the question? – Freddie Bell Nov 23 '19 at 10:09
  • @nolaspeaker how do you configure the client side? it is in the beginning. – Nasreddine Galfout Nov 23 '19 at 10:49
  • What does "configure" mean? – Freddie Bell Nov 23 '19 at 10:56
  • [Configure](https://en.wiktionary.org/wiki/configure) "To set up or arrange something in such a way that it is ready for operation for a particular purpose, or to someone's particular liking", so in this case, how to set-up the TRESTClient to be able to operate using TLS. – GolezTrol Nov 23 '19 at 12:58
  • @GolezTrol what makes you think there is anything to configure, besides the `SecureProtocols`? – Remy Lebeau Nov 23 '19 at 16:21
  • sorry for my confusing question, the point is I want to make the packet data unreadable by the sniffer and I think by doing the correct configuration on TRESTClient will make it happen – mgk Nov 23 '19 at 22:41
  • @RemyLebeau I don't know. In the past extra dll's were needed for SSL. I'd assume that is still the case, but Embarcadero's documentation on this property is -as usual- non-existent, and OP apparently misses some step. The question may not be great, but seems fair, so my response was mainly aimed at nolaspeaker who seems to want to cover it in riddles. – GolezTrol Nov 24 '19 at 07:50

0 Answers0