Indy IOHandlerTls - How to setup correctly for Https in .NET?


2006-08-12 05:00:24 PM
delphi138
Hi Folks,
I'm just hoping someone here might be able to help me with a query.
I'm new to this part of it Indy, but am a user of D2005, and trying to
setup an IOHandlerTls in a .NET application to try to get Https working.
I'll be honest, I could use some comments on how to correctly set it up.
Delphi Version: 2005 Update 3
Indy Version: 10.1.5
Currently, I have created the objects like this:
FHttp := TidHttp.Create;
FSsl := TIdIOHandlerTls.Create;
FSsl.Options.Protocol := SecurityProtocolType.Default; // tried .Tls
sDir := Path.GetDirectoryName(Application.ExecutablePath);
sCert := sDir + '\Key\mycert.cer';
//sKey := sDir + '\Key\mykey.key';
cert := X509Certificate.CreateFromFile(sCert);
FSsl.Options.CertificateCollection :=
X509CertificateCollection.Create;
FSsl.Options.CertificateCollection.Add(cert);
FHttp.IOHandler := FSsl;
try
sResponse := FHttp.Get('https://sourceforge.net/account/login.php');
except
// on exception re-raise just for testing purposes
raise;
end;
Whenever I call FHttp.Get on an https address I get an exception:
Exception Class: IOException
Message: The authentication or decryption has failed.
So obviously I have missed something out. Anyone able to help fill the
knowledge gap here please?
It would be nice if I could get one working, it could form an example.
There seem to be a lot of other people interested in getting this
working correctly. :)
Kind regards, and thanks in advance,
Scott :)