Recent

Author Topic: lnet http problem - Needs OpenSSL library  (Read 18207 times)

szocsmarci

  • New member
  • *
  • Posts: 8
lnet http problem - Needs OpenSSL library
« on: March 29, 2011, 11:00:10 am »
Hi
I have a a problem with lnet.

Newly installed Lazarus (0.9.30) + FPC 2.4.2 + lnet 0.6.5

In the example program - visual/http/httpclienttest - it quits with this message: Unable to initialize OpenSSL library, please Check your OpenSSL installation.

I read that lnet doesn't have other dependecies - no need other libraries than FPC and lazarus.

I found the OpnSSL directory in the FPC/2.4.2/source and in the FPC/2.4.2/units directories too, so FPC contains them.

What do I need to do to install OpenSSL?

Dibo

  • Hero Member
  • *****
  • Posts: 1046
Re: lnet http problem - Needs OpenSSL library
« Reply #1 on: March 29, 2011, 12:32:46 pm »
On linux systems OpenSSL is installed by default. On windows you should install OpenSSL librarys:
http://www.openssl.org/related/binaries.html
If installer doesn't copy libeay32.dll and ssleay32.dll to Windows\System32 folder then you should do this manually (You find them in OpenSSL installation dir). You can copy this librarys to your exe dir instead of System32.

szocsmarci

  • New member
  • *
  • Posts: 8
Re: lnet http problem - Needs OpenSSL library
« Reply #2 on: March 30, 2011, 08:33:39 am »
Thanks it works!  ;D

But why it is written, that lnet had no dependecies (except FPC, and Lazarus)?

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: lnet http problem - Needs OpenSSL library
« Reply #3 on: March 30, 2011, 09:59:20 am »
And system libraries that it is using, like *all* the code you write ...

Dibo

  • Hero Member
  • *****
  • Posts: 1046
Re: lnet http problem - Needs OpenSSL library
« Reply #4 on: March 30, 2011, 02:10:18 pm »
I have question about OpenSSL too. Can I include this librarys into installator of my application without breaking the OpenSSL license? I just want that user download my program and run without installation external librarys. How it works on internet browser? They using somehow SSL and I don't need install OpenSSL

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7630
Re: lnet http problem - Needs OpenSSL library
« Reply #5 on: March 30, 2011, 05:01:43 pm »
I have question about OpenSSL too. Can I include this librarys into installator of my application without breaking the OpenSSL license? I just want that user download my program and run without installation external librarys. How it works on internet browser? They using somehow SSL and I don't need install OpenSSL

It's in the installer. E.g. Mozilla firefox has a libssl3.dll in its Windows install.

Almindor

  • Sr. Member
  • ****
  • Posts: 411
    • http://www.astarot.tk
Re: lnet http problem - Needs OpenSSL library
« Reply #6 on: March 31, 2011, 12:49:53 pm »
Thanks it works!  ;D

But why it is written, that lnet had no dependecies (except FPC, and Lazarus)?


lNet itself has no dependencies, and produces "smartlinked" code with FPC.

OpenSSL support however is a functionality requiring external library and if you use it (TLSSLSession) then you will need this library. One could write a SSL library in FPC for example, but that's a huge undertaking and is also risky (openSSL is tried and true, and responds to security issues).

For distribution needs, you can include the openSSL library (dll) for windows in your application provided you comply with their license (I think a readme might be sufficient).

Raul_ES

  • Jr. Member
  • **
  • Posts: 73
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: lnet http problem - Needs OpenSSL library
« Reply #7 on: May 11, 2019, 02:02:52 am »
Hi!

today 11-5-2019 I still have this exact problem when running LNet samples, both in Windows and Linux. Anyone else has the same issue?
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

JimD

  • Jr. Member
  • **
  • Posts: 62
Re: lnet http problem - Needs OpenSSL library
« Reply #8 on: May 17, 2019, 05:35:48 pm »
Hi Raul,

This example works for me on Windows.

I downloaded the OpenSSL 1.0.2r windows binaries reference this post:
https://forum.lazarus.freepascal.org/index.php/topic,44554.msg313449.html#msg313449

I copied the libeay32.dll and ssleay32.dll files in the same folder:
lnet\examples\visual\http

I tested with the url https://google.com

My Config: Win10 Home 64-bit, Lazarus 1.8.2, FPC 3.0.4 64



trev

  • Sr. Member
  • ****
  • Posts: 258
  • Former Delphi 7 and Delphi 10.2 User
Re: lnet http problem - Needs OpenSSL library
« Reply #9 on: June 20, 2019, 01:48:16 pm »
For Windows I use Microsoft's WinInet API (https://docs.microsoft.com/en-us/windows/desktop/wininet/wininet-reference):

Code: Pascal  [Select]
  1. {$IFDEF WINDOWS}
  2. // Need to use Windows WinInet to avoid issue with HTTPS
  3. // needing two OpenSSL DLLs to be provided with application
  4. // if using TFPHttpClient.
  5. // The WinINet API also gets any connection and proxy settings
  6. // set by Internet Explorer... curse or blessing?
  7.  
  8. function GetSSLPage(const Url: string): string;
  9. var
  10.   NetHandle: HINTERNET;
  11.   UrlHandle: HINTERNET;
  12.   Buffer: array[0..1023] of Byte;
  13.   BytesRead: dWord;
  14.   StrBuffer: UTF8String;
  15. begin
  16.   Result := '';
  17.   NetHandle := InternetOpen('Mozilla/5.0(compatible; WinInet)', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  18.  
  19.   // NetHandle valid?
  20.   if Assigned(NetHandle) then
  21.     Try
  22.       UrlHandle := InternetOpenUrl(NetHandle, PChar(Url), nil, 0, INTERNET_FLAG_RELOAD, 0);
  23.  
  24.       // UrlHandle valid?
  25.       if Assigned(UrlHandle) then
  26.         Try
  27.           repeat
  28.             InternetReadFile(UrlHandle, @Buffer, SizeOf(Buffer), BytesRead);
  29.             SetString(StrBuffer, PAnsiChar(@Buffer[0]), BytesRead);
  30.             Result := Result + StrBuffer;
  31.           until BytesRead = 0;
  32.         Finally
  33.           InternetCloseHandle(UrlHandle);
  34.         end
  35.       // o/w UrlHandle invalid
  36.       else
  37.         raise Exception.CreateFmt('Cannot retrieve %s', [Url]);
  38.     Finally
  39.       InternetCloseHandle(NetHandle);
  40.     end
  41.   // NetHandle invalid
  42.   else
  43.     raise Exception.Create('Unable to initialise WinInet');
  44. end;
  45. {$ENDIF}
  46.  

You need to add WinInet to the Uses clause.
o Lazarus v2.1.0 r61775, FPC v3.3.1 r42640, macOS 10.14.6 (with sup update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)