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;
<...>
TScSSLClient
Re: TScSSLClient
...and it is returning a response with RichThinClient and Indy with OpenSSL.
Re: TScSSLClient
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;