Recent

Author Topic: Could not initialize openssl library?  (Read 3781 times)

Espectr0

  • Full Member
  • ***
  • Posts: 221
Could not initialize openssl library?
« on: June 11, 2023, 01:47:28 am »
Hola,
what can go wrong in linux mint, that I get the message "Could not initialize openssl library"...
Do I need to configure something special?

Code: Pascal  [Select][+][-]
  1.  
  2. uses opensslsockets;
  3. ...
  4. FHTTPClient.AllowRedirect := True;
  5. FHTTPClient.HTTPMethod(FMethod, AURL, FDS, [200]);
  6.  

openssl is installed.

Thanks!

Thaddy

  • Hero Member
  • *****
  • Posts: 17176
  • Ceterum censeo Trump esse delendam
Re: Could not initialize openssl library?
« Reply #1 on: June 11, 2023, 09:58:02 am »
What protocol are you requesting? It should be TLS1.2 or higher. Usually the OpenSSL version for Mint is up to date and so will refuse anything below TLS1.2
[edit]
I just got the same error using fpcupdeluxe on windows 10.
While searching for an answer  I discoverd:
1. The current stable of openssl is 3.1
2. This is not yet supported by fpc
3. But openssl 1.1.1u (lts) is supported by fpc.
4. so check in a terminal using: openssl version

Also note fpcdupeluxe worked yesterday so currently I am at a loss.
Investigating...
I have to exactly the same laptops, with slightly differing versions of Windows 10: one works as of today, the one I am using now doesn't.
Strange. So it is probably not related to Mint, but the presence of openssl 1.1.1.
« Last Edit: June 11, 2023, 11:15:18 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Espectr0

  • Full Member
  • ***
  • Posts: 221
Re: Could not initialize openssl library?
« Reply #2 on: June 11, 2023, 12:55:02 pm »
The version installed is v3.0.2 15 Mar 2022.
It is not supported by fpc?

paweld

  • Hero Member
  • *****
  • Posts: 1420
Re: Could not initialize openssl library?
« Reply #3 on: June 11, 2023, 01:28:14 pm »
fpc trunk only.   
or use synapse
Best regards / Pozdrawiam
paweld

Espectr0

  • Full Member
  • ***
  • Posts: 221
Re: Could not initialize openssl library?
« Reply #4 on: June 11, 2023, 02:10:10 pm »
Thanks

Thaddy

  • Hero Member
  • *****
  • Posts: 17176
  • Ceterum censeo Trump esse delendam
Re: Could not initialize openssl library?
« Reply #5 on: June 11, 2023, 02:45:30 pm »
fpc trunk only.   
or use synapse
Since when does synapse support openssl 3.x? It does not.
Also I use mainly trunk (always recent) and trunk also does not support openssl 3.x.
It supports the long time support version of openssl 1.1.1.
openssl 3.x has a quite breaking changed API as opposed to 1.x, mostly caused by the fact that it is a complete rewrite in C++ where older versions are plain C.
« Last Edit: June 11, 2023, 02:50:29 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rvk

  • Hero Member
  • *****
  • Posts: 6777
Re: Could not initialize openssl library?
« Reply #6 on: June 11, 2023, 03:39:42 pm »
fpc trunk only.   
or use synapse
Since when does synapse support openssl 3.x? It does not.
Since trunk R260.
https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/

See ssl_openssl3.pas.

WayneSherman

  • Sr. Member
  • ****
  • Posts: 255
Re: Could not initialize openssl library?
« Reply #7 on: June 27, 2023, 06:55:32 pm »
Also I use mainly trunk (always recent) and trunk also does not support openssl 3.x.
It supports the long time support version of openssl 1.1.1.
openssl 3.x has a quite breaking changed API as opposed to 1.x...

FPC trunk has support for OpenSSL 3.0 since 2022-April:
https://gitlab.com/freepascal.org/fpc/source/-/commit/59672a698267ca16ea8812f4acf932f127cc7bc0
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/openssl/src/openssl.pas#L111

abouchez

  • Full Member
  • ***
  • Posts: 125
    • Synopse
Re: Could not initialize openssl library?
« Reply #8 on: July 25, 2023, 04:07:06 pm »
Note that mORMot 2 has OpenSSL support from 1.1 to 3.x with automatic adaptation of the API.
It works with FPC 3.x compiler.

See https://github.com/synopse/mORMot2/blob/master/src/lib/mormot.lib.openssl11.pas for the raw API
and https://github.com/synopse/mORMot2/blob/master/src/crypt/mormot.crypt.openssl.pas for a set of high-level wrapper interfaces.

Note that some API is broken between 1.1 and 3.x e.g. some functions did disappear, be renamed, or changed parameter size (from 32-bit to 64bit).
So you need more than adding a dll name search to fully support the 3.x branch.
We tested and validated our wrapper on several Linux and Windows systems, and including Mac M1.

Also note that, from my experiment, OpenSSL 3.0 is way slower than OpenSSL 1.1 when setting up its internal structures and objects: for huge buffers, it is fine, but for small buffers, it has a huge overhead. It is about to be fixed in upcoming OpenSSL 3.1 IIRC.
« Last Edit: July 25, 2023, 04:23:47 pm by abouchez »

Fred vS

  • Hero Member
  • *****
  • Posts: 3624
    • StrumPract is the musicians best friend
Re: Could not initialize openssl library?
« Reply #9 on: April 11, 2025, 05:08:37 pm »
Hello.

I have the same problem here on Windows 11 (on Unix OS, all is ok) with radio web streaming of mp3 and aac format.

But the strange thing is that I get it only for few url.

This is ok, no error: http://stream-uk1.radioparadise.com/mp3-128

But with this: https://radiorecord.hostingradio.ru/sd9096.aacp

There is error while trying a http.get() or http.head().
Code: Pascal  [Select][+][-]
  1. Could not initialize OpenSSL library

So I dont understand why for some url initialize OpenSSL is ok and for others not.

I am using fpc 3.2.2 64 bit on Windows 11.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

rvk

  • Hero Member
  • *****
  • Posts: 6777
Re: Could not initialize openssl library?
« Reply #10 on: April 11, 2025, 05:10:44 pm »
But the strange thing is that I get it only for few url.

This is ok, no error: http://stream-uk1.radioparadise.com/mp3-128

But with this: https://radiorecord.hostingradio.ru/sd9096.aacp
Notice that the first is HTTP (so without S) and the second is HTTPS.
You only need openssl libs for HTTPS urls.

Make sure you have the correct ones in you exe directory.

Fred vS

  • Hero Member
  • *****
  • Posts: 3624
    • StrumPract is the musicians best friend
Re: Could not initialize openssl library?
« Reply #11 on: April 11, 2025, 05:29:31 pm »
Ho, you just answerd before I wanted to add a info:

For http://stream-uk1.radioparadise.com/mp3-128 if you click on it here on the forum post, it will redirect to the same with a 's' --->
https://stream-uk1.radioparadise.com/mp3-128

And it works.

Quote
You only need openssl libs for HTTPS urls.
Make sure you have the correct ones in you exe directory.

Ha, ok, thanks.
Hum, even if Windows was my first love (when it appeared long time ago), I did not follow it since XP.
So the re-beginner question from where to download it?
And is it possible to use the native ssl libs of Windows instead?
Should I switch for something else than fpc TFPHTTPClient to have something more 'out-of-the-box'?
Maybe use mORMot 2?
And maybe solve also this?: https://forum.lazarus.freepascal.org/index.php/topic,70773.0.html

Anyway, thanks rvk for your help and light.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3624
    • StrumPract is the musicians best friend
Re: Could not initialize openssl library?
« Reply #12 on: April 11, 2025, 05:54:55 pm »
You only need openssl libs for HTTPS urls.
Make sure you have the correct ones in you exe directory.

Re-hello.

I am a few lost.
What is the name of those openssl libs and what version should be used for fpc 3.2.2 Windows 32 and 64 bit?
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

rvk

  • Hero Member
  • *****
  • Posts: 6777
Re: Could not initialize openssl library?
« Reply #13 on: April 11, 2025, 06:28:50 pm »
So the re-beginner question from where to download it?
And is it possible to use the native ssl libs of Windows instead?
With TFPHTTPClient you do need the openssl libs. Of you want to use the native Windows download you need to do something like URLDownloadToFile from the Windows API.

I'm not sure what a current download location for the latest openssl is.
In the past there was https://indy.fulgan.com/SSL/
I see they are still current but thought it wasn't the preferred download of Indy anymore. They only have 1.0.2 there but that might be sufficient for you. You can use the latest 1.0.2 version for 32 and 64 bit versions there.  If you want 1.1 and higher you'll need their GitHub but I don't know the location from memory.



Fred vS

  • Hero Member
  • *****
  • Posts: 3624
    • StrumPract is the musicians best friend
Re: Could not initialize openssl library?
« Reply #14 on: April 11, 2025, 06:36:10 pm »
So the re-beginner question from where to download it?
And is it possible to use the native ssl libs of Windows instead?
With TFPHTTPClient you do need the openssl libs. Of you want to use the native Windows download you need to do something like URLDownloadToFile from the Windows API.

I'm not sure what a current download location for the latest openssl is.
In the past there was https://indy.fulgan.com/SSL/
I see they are still current but thought it wasn't the preferred download of Indy anymore. They only have 1.0.2 there but that might be sufficient for you. You can use the latest 1.0.2 version for 32 and 64 bit versions there.  If you want 1.1 and higher you'll need their GitHub but I don't know the location from memory.

Yep, perfect, I will try, many thanks.

Have a perfect day.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018