-1

Doing so, I should get the public IP:

function TForm1.GetPublicIp: String;
begin
  IdHttp1.Request.Host := 'https://www.mio-ip.it';
  Result := IdHttp1.Get('https://www.mio-ip.it');
end;

The problem is that even if I fill it out without errors, it raises an error when I press the button:

IOHandler value is not valid

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
MrCamarium
  • 5
  • 1
  • 5

2 Answers2

0

You are requesting an HTTPS url. In order to use HTTPS (HTTP over SSL/TLS) with TIdHTTP, you need to assign a TIdSSLIOHandlerSocketBase-derived component to the TIdHTTP.IOHandler property, such as TIdSSLIOHandlerSocketOpenSSL. Also see New HTTPS functionality for TIdHTTP on Indy's blog.

Using TIdSSLIOHandlerSocketOpenSSL, you will have to deploy the 2 OpenSSL binaries with your app, ssleay32.dll and libeay32.dll. You can get them from Indy's OpenSSL-Binaries GitHub repo. Just note that TIdSSLIOHandlerSocketOpenSSL supports up to OpenSSL 1.0.2u. If you need OpenSSL 1.1.x instead (for TLS 1.3, etc), you can use this Work-in-Progress SSLIOHandler instead.

Or, you can use any other SSL/TLS library you want, as long as you can find (or write) an SSLIOHandler for it. For example, SecureBlackbox provides an SSLIOHandler for its own SSL/TLS engine. And this GitHub repo has an SSLIOHandler for LibTLS.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
0

Also you can use TNetHTTPClient for Delphi XE8 and up