TScSSLClient

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
JackBaird
Posts: 2
Joined: Wed 14 Jan 2015 21:38

TScSSLClient

Post by JackBaird » Wed 14 Jan 2015 21:49

I'm trying to send a raw XML transaction to a server using HTTPS. Unfortunately, I purchased SecureBridge prior to discovering that there are no demos of the TScSSLClient class.

Could you please reply with a simple HTTPS POST example? The snippet below doesn't return anything back (TScSSLClient.InCount results in 0). What am I doing wrong here?

<...>
HTTP := TScSSLClient.Create(nil);
try
HTTP.HostName := URL;
HTTP.Port := 443;
HTTP.IsSecure := True;
HTTP.OnServerCertValidate := CertValidate;
HTTP.Protocols := [spSsl3];
HTTP.NonBlocking := True;
HTTP.WriteBuffer(Buffer, Request.Size);
if (HTTP.InCount > 0) then
begin
SetLength(InBuffer, HTTP.InCount);
HTTP.ReadBuffer(InBuffer, HTTP.InCount);
Response := StringOf(InBuffer);
MessageDlg(Response, mtInformation, [mbOK], 0);
end
else
begin
raise Exception.Create('Empty HTTPS result!');
end;
finally
Request.Free;
RequestText.Free;
HTTP.Free;
end;
<...>

JackBaird
Posts: 2
Joined: Wed 14 Jan 2015 21:38

Re: TScSSLClient

Post by JackBaird » Wed 14 Jan 2015 22:00

...and it is returning a response with RichThinClient and Indy with OpenSSL.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TScSSLClient

Post by ViktorV » Thu 29 Jan 2015 12:50

To solve the problem, you should call the TScSSLClient.Conneсt method before setting the IsSecure property to True. For example:

Code: Select all

  HTTP.HostName := URL;
  HTTP.Port := 443;
  HTTP.NonBlocking := True;
  HTTP.Protocols := [spSsl3];
  HTTP.OnServerCertValidate := CertValidate;
  HTTP.Connect;
  HTTP.IsSecure := True;

Post Reply