* * *

Author Topic: Do the SSL libraries not work in Lazarus?  (Read 871 times)

MarkAurelius

  • Newbie
  • Posts: 4
Do the SSL libraries not work in Lazarus?
« on: June 08, 2017, 06:50:46 am »
Hi

I wrote a small app that reads an HTTP url to grab a page of JSON.

This is the code, which compiles in both Delphi and Lazarus:

Code: Pascal  [Select]
  1. function ReadHTTPS(const url: string): string;
  2. var
  3.   IdHTTP: TIdHTTP;
  4.   IdSSL: TIdSSLIOHandlerSocketOpenSSL;
  5. begin
  6.   IdHTTP := TIdHTTP.Create;
  7.   try
  8.     IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP);
  9.     IdHTTP.IOHandler := IdSSL;
  10.     result := IdHTTP.Get(url);
  11.   finally
  12.     IdHTTP.Free;
  13.   end;
  14. end;
  15.  

To get that to work in Delphi I dropped in 2 library files, ssleay32.dll and libeay32.dll. I moved that same files over to the a lazarus project but when it runs IdHTTP.Get(url)  I get an exception saying "Could not load SSL libraries.

I expect people have solved this before. And advice?

Regards
Mark

To answer Thaddy's questions on the versions:
My machine with both Delphi and Lazarus installed has 64 bit windows 7.

The Delphi is 10.1 Berlin.I have had this working with both 32 and 64 bit targets.

The Lazarus is 1.6.4. It was installed from lazarus-1.6.4-fpc-3.0.2-win64.exe

And that was the problem! It worked once I had the 64 bit libraries in place! I think I wasn't giving FPC credit for 64-bit.
« Last Edit: June 13, 2017, 07:17:15 am by MarkAurelius »

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Do the SSL libraries not work in Lazarus?
« Reply #1 on: June 08, 2017, 08:51:36 am »
What version of Delphi? What version of Indy? What version of Lazarus? And do you use 32 bit or 64 bit?
For Lazarus 64 bit you will need 64 bit compiled openssl dll's. 32 bit works only with 32 bit Lazarus.
I expect that you are using Windows? Because the libraries are platform specific, i.e. the openssl dll's of course won't work on Linux.

Properly set up, your code not only compiles but simply works. I suspect that you use 64 bit Laz ...and try to load 32 bit openssl dll's.

http://www.indyproject.org/Sockets/fpc/OpenSSLforWin64.en.aspx
« Last Edit: June 08, 2017, 09:00:51 am by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Do the SSL libraries not work in Lazarus?
« Reply #2 on: June 08, 2017, 09:08:06 am »
Note that the naming of these dll's you can obtain from that link is actually plain wrong and confusing. They still suggest 32 bit but ARE 64 bits. Maybe Remy can fix that....?
« Last Edit: June 08, 2017, 11:03:18 am by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Phil

  • Hero Member
  • *****
  • Posts: 2279
Re: Do the SSL libraries not work in Lazarus?
« Reply #3 on: June 08, 2017, 03:34:43 pm »
Note that the naming of these dll's you can obtain from that link is actually plain wrong and confusing. They still suggest 32 bit but ARE 64 bits. Maybe Remy can fix that....?

Confusing, but as intended. See the note about naming in the link.

More up to date libraries are here. Those are old.

https://indy.fulgan.com/SSL/

MarkAurelius

  • Newbie
  • Posts: 4
Re: Do the SSL libraries not work in Lazarus?
« Reply #4 on: June 13, 2017, 07:23:26 am »
Properly set up, your code not only compiles but simply works. I suspect that you use 64 bit Laz ...and try to load 32 bit openssl dll's.

http://www.indyproject.org/Sockets/fpc/OpenSSLforWin64.en.aspx

Yes, that was it! I don't know why I didn't try that out when I was first doing this. Thanks for pointing me to the obvious.
« Last Edit: June 13, 2017, 07:59:56 am by MarkAurelius »

Thaddy

  • Hero Member
  • *****
  • Posts: 4439
Re: Do the SSL libraries not work in Lazarus?
« Reply #5 on: June 13, 2017, 08:01:54 am »
More up to date libraries are here. Those are old.

https://indy.fulgan.com/SSL/

Yes. Much better binaries. Tnx.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus