Skip to content

Commit

Permalink
Merge pull request #214 from mateusvicente100/master
Browse files Browse the repository at this point in the history
Accept APIs with invalid certificate
  • Loading branch information
viniciussanchez authored Jul 9, 2024
2 parents 9ba5e79 + 57fa5b0 commit 5f3fa53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/RESTRequest4D.Request.NetHTTP.pas
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ TRequestNetHTTP = class(TInterfacedObject, IRequest)
function MakeURL(const AIncludeParams: Boolean = True): string;
function Proxy(const AServer, APassword, AUsername: string; const APort: Integer): IRequest;
function DeactivateProxy: IRequest;
procedure NetHTTPClientValidateServerCertificate(const Sender: TObject; const ARequest: TURLRequest; const Certificate: TCertificate; var Accepted: Boolean);
protected
procedure DoAfterExecute(const Sender: TObject; const AResponse: IHTTPResponse); virtual;
procedure DoBeforeExecute(const Sender: TNetHTTPClient); virtual;
Expand Down Expand Up @@ -371,6 +372,7 @@ constructor TRequestNetHTTP.Create;
FNetHTTPClient.OnRequestCompleted := DoAfterExecute;
FNetHTTPClient.Asynchronous := False;
FNetHTTPClient.SynchronizeEvents := True;
FNetHTTPClient.OnValidateServerCertificate := NetHTTPClientValidateServerCertificate;

FParams := TStringList.Create;
FUrlSegments := TStringList.Create;
Expand Down Expand Up @@ -558,6 +560,11 @@ function TRequestNetHTTP.MakeURL(const AIncludeParams: Boolean): string;
end;
end;

procedure TRequestNetHTTP.NetHTTPClientValidateServerCertificate(const Sender: TObject; const ARequest: TURLRequest; const Certificate: TCertificate; var Accepted: Boolean);
begin
Accepted := True;
end;

class function TRequestNetHTTP.New: IRequest;
begin
Result := TRequestNetHTTP.Create;
Expand Down

0 comments on commit 5f3fa53

Please sign in to comment.