Recent

Author Topic: OpenSSL initialize error  (Read 563 times)

jhorta

  • New member
  • *
  • Posts: 7
OpenSSL initialize error
« on: November 26, 2024, 10:21:32 pm »
While I don't get any feedback on the topic https://forum.lazarus.freepascal.org/index.php/topic,69451.0.html, I decided to deploy the API to the cloud (AWS). It turns out that in this case the call is https and according to information on the web, it is necessary to add the opensslsockets package in the uses clause. After doing this, I am getting an error, Could not initialize OpenSSL library. Everything Works fine when i call via Postman. I appreciate any help to get around this problem.

Running on Windows 10, Lazarus 3.4

Error: Could not initialize OpenSSL library

My code:

Code: Pascal  [Select][+][-]
  1. Procedure Send;
  2. Var Client: TFPHttpClient;
  3.     Response: TStringStream;
  4. Begin
  5.    Client := TFPHttpClient.Create(nil);
  6.    Client.AddHeader('Content-Type', 'application/json; charset=UTF-8');
  7.    Client.RequestBody := TRawByteStringStream.Create('{"jwt": "", ' + '"codAplicacao": "F60EB930-9B1B-11EF-9657-02240D86274B"}');
  8.  
  9.    Response := TStringStream.Create('');
  10.  
  11.    Try
  12.       Try
  13.          //Client.Post('http://localhost:4000/local/inicio/hortech', Response);
  14.          Client.Post('https://mystack.execute-api.us-east-2.amazonaws.com/dev/inicio/hortech', Response);
  15.          GeraLog('Response: ' + String(Response));
  16.        Except on E: Exception do
  17.           Begin
  18.              GeraLog('Something wrong: ' + E.Message);
  19.           End;
  20.        End;
  21.    Finally
  22.        Client.RequestBody.Free;
  23.        Client.Free;
  24.        Response.Free;
  25.    End;
  26. End;
  27.  

TRon

  • Hero Member
  • *****
  • Posts: 3822
Re: OpenSSL initialize error
« Reply #1 on: November 26, 2024, 10:30:35 pm »
Try installing the ssl dev package on your distro. strace can be used for details for failure of finding/opening the library.
I do not have to remember anything anymore thanks to total-recall.

jhorta

  • New member
  • *
  • Posts: 7
Re: OpenSSL initialize error
« Reply #2 on: November 26, 2024, 10:49:22 pm »
Thanks for the quick reply. Your mention of 'distro' reinforces to me that I'm on a Windows environment.

As for the suggested installation, I'm quite confused. I've read several threads about the same issue and each one uses a different approach. Some suggest copying one or two dlls to the executable folder. Could you elaborate on this process for a Windows 10 environment?

Thanks again.

TRon

  • Hero Member
  • *****
  • Posts: 3822
Re: OpenSSL initialize error
« Reply #3 on: November 26, 2024, 11:01:32 pm »
Sorry, my bad jhorta. I wrongfully assumed *nix environment.

The dll bitness (32 vs 64-bit) has to match the bitness of your executable.

The easiest would be for all (openssl might be accompanied with cryptolibs) the libraries to placed next to your executable.

for a system-wide installation of the openssl-libraries I do not have a clear answer for you as I am not a windows user (anymore). The locations are at first sight illogical e.g. 32-bit dll's inside a 64-bit named folder.

EDIT:
for the system-wide locations on window, see this post from Thaddy (but the whole thread might perhaps be of interest)
« Last Edit: November 26, 2024, 11:43:08 pm by TRon »
I do not have to remember anything anymore thanks to total-recall.

 

TinyPortal © 2005-2018