Including OpenSSL in a cross-platform application lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- maurobio · 2023-09-07 19:22 Dear ALL, Hi! So, I have a cross-platform application which uses OpenSSL. When creating a version for Windows, it is simple enough to include the shared libraries "ssleay32.dll" and "libeay32.dll" in the project folder and that is that. But things become a little bit more complicated when creating a Linux version. In Linux, the equivalent of the above shared libraries are "libcrypto.so" and "libssl.so", but to begin with, I have not been able to locate these files. Second, I downloaded static versions of these libraries from here https://indy.fulgan.com/SSL/, but I could not figure out how to compile the application with them included, which does not seem to be a very bright idea anyway. Ideally, I would like to use the dynamic versions of the libraries and put them in an adequate folder (eg. /usr/lib) when creating a distribution paclage. Could someone out there please give me some hints on how to get this done? Thanks in advace for any assistance you can provide. With warmeest regards, ---------------------------------------------------------------------- delphius · 2023-09-07 20:24 Quote from: maurobio on September 07, 2023, 09:22:15 pmCould someone out there please give me some hints on how to get this done? Linux usually has openssl libs pre-installed, but the latest version is .3, if you use the fpc trunk version of the module openssl.pas, then it already includes support for these versions: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DLLVersions: array[1..20] of AnsiString = ('','.3', '.1.1', '.11', '.10', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',                                      '.1.0.2', '.1.0.1','.1.0.0','.0.9.8',                                      '.0.9.7', '.0.9.6', '.0.9.5', '.0.9.4',                                      '.0.9.3', '.0.9.2', '.0.9.1');  If it is NOT, then you can use a trick: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         if not InitSSLInterface then          begin            openssl.DLLVersions[1] := '.3';          end;        if not InitSSLInterface then          begin            exit; // no ssl        end; In my simple Indy fpmailsend repo there are latest .so biraries precompiled for linux. Cause I use Indy so can use .so libs from program folder just with: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...uses IdS SLOpenSSLHeaders;...IdOpenSSLSetLibPath(ExtractFilePath(ParamStr(0))); ... ---------------------------------------------------------------------- maurobio · 2023-09-07 20:40 Ave, @delphius! Gratias! QuoteCause I use Indy and so can use .so libs from program folder just with: Aha! That's is the trick I was looking for! I will try it ASAP. Thank you very much! With warmest regards, ---------------------------------------------------------------------- maurobio · 2023-09-07 21:13 Hi, @delphius! I have found a problem with the Indy-based solution. It is not an error, but just a "quirk". As it happens, my application does not uses Indy, but the regular OpenSSL library included with Lazarus. Is there any way of getting a similar solution to that you offered, but one not one based on Indy? Thank you very much! With warmest regards, ---------------------------------------------------------------------- delphius · 2023-09-07 21:38 Quote from: maurobio on September 07, 2023, 11:13:22 pmIs there any way of getting a similar solution to that you offered, but one not one based on Indy? May be you can use this? ---------------------------------------------------------------------- abouchez · 2023-09-08 07:28 With our https://github.com/synopse/mORMot2/blob/master/src/lib/mormot .lib.openssl11.pas unit, we had to manage the changing names and detect the version to adapt the calls to some OpenSSL APIs at runtime. Note that some OpenSSL APIs are inconsistent between 1.x and 3.x branches. Check how our unit knows how to adapt: https://github.com/synopse/mORM ot2/blob/master/src/lib/mormot.lib.openssl11.pas#L3360 This unit is not based on Indy or FPC RTL, and also works on Delphi. It has some object-based wrappers to the most used structures, so it may be easier to work than plain OpenSSL calls. And it is used on production on several systems (including Mac M1). ---------------------------------------------------------------------- Remy Lebeau · 2023-09-08 17:43 Quote from: delphius on September 07, 2023, 10:24:50 pmIn my simple Indy fpmailsend repo there are latest .so biraries precompiled for linux. Cause I use Indy so can use .so libs from program folder just with: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...uses IdS SLOpenSSLHeaders;...IdOpenSSLSetLibPath(ExtractFilePath(ParamStr(0))); ... Just be aware that Indy dynamically loads the unversioned libs by default, which is becoming more of a problem as OpenSSL 1.1/3.0 distributions are becoming more common.  It means the libs are mapping to newer OpenSSL versions that are not compatible with Indy, causing runtime errors.  Fortunately, you can call IdOpenSSLSetCanLoadSymLinks(False) and/or IdOpenSSLSetLoadSymLinksFirst(False) at app startup to make Indy load the versioned libs instead, and then it will only load compatible versions. ---------------------------------------------------------------------- maurobio · 2023-09-09 13:13 Hi, gentlemen! I also found this possible simple solution: https://forum.lazarus.freepascal.org/index.php?topic=21972.0 More soon... Best regards, ---------------------------------------------------------------------- maurobio · 2023-09-09 14:30 Gentlemen, As it turned out, my problems are uglier than I thought at first. I will provide a concise description of them below, in the hope that some of you can enlighten me towards a solution. I have a (relatively) simple cross-platform application that fetches data from several online databases to present information on biological species in an integrated format (the full source code can be found here: https://github.com/maurobio/especies. It compiles and runs without problems under Windows and Linux but (there is always a "but"!) only in a machine that has Lazarus installed. On a machine which has not Lazarus installed, it fails with an "Access violation" error and that is that. The application uses units fphttpclient, openssl, opensslsockets, DOM, XMLRead, and XPath; therefore it depends upon the OpenSSL and Expat libraries which are, of course, installed along with Lazarus in a regular installation of the IDE. I thought at first that it should be a simple matter of including these libraries in the application folder (at least under Windows), but this do not work. In Windows, I first put the required libraries (libeay32.dll, ssleay32.dll, libexpat.dll) in the application folder, but got an error saying something about the libraries not being compiled for use under Windows. I then installed the OpenSSL binaries (from here: https://slproweb.com/products/Win32OpenSSL.html), but it did not work either (that is, the application keeps issuing the "Access violation" error). Under Linux the situation is, of course, a little bit more complicated. In an installation of Linux Mint 21 (without Lazarus installed), I found libssl installed but NOT libcrypto. What I want it to provide these libraries to users, along with the installation packages for both the Windows and Linux versions. Under Linux, I create a Debian package for distribution the application and so I presume I should include these libraries in the list of dependencies. Under Windows, I use InnoSetup to create executable installation packages and I suppose I should include the required libraries in it to be put in the Windows/System folder. I have successfully deployed other application developed with FPC/Lazarus using both methods, but none of these applications are dependent of these libraries. Are there some simple and clean ways of getting out of this mess? Thanks in advance for any assistance you can provide! With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-09 15:39 Quote from: maurobio on September 09, 2023, 04:30:42 pmI thought at first that it should be a simple matter of including these libraries in the application folder (at least under Windows), but this do not work. In Windows, I first put the required libraries (libeay32.dll, ssleay32.dll, libexpat.dll) in the application folder, but got an error saying something about the libraries not being compiled for use under Windows."A error saying something". Lovely description. If you want help with this ALWAYS note the EXACT error message. BTW. Did you match the bitness of the dll's correctly. (i.e. your application 64 bit, dll 64 bit / app 32 bit, dll 32 bit) Quote from: maurobio on September 09, 2023, 04:30:42 pm I then installed the OpenSSL binaries (from here: https://slproweb.com/products/Win32OpenSSL.html), but it did not work either (that is, the application keeps issuing the "Access violation" error). Quote from: maurobio on September 09, 2023, 04:30:42 pmUnder Linux the situation is, of course, a little bit more complicated. In an installation of Linux Mint 21 (without Lazarus installed), I found libssl installed but NOT libcrypto.libcrypto is something else. Why do you need that? Quote from: maurobio on September 09, 2023, 04:30:42 pmUnder Windows, I use InnoSetup to create executable installation packages and I suppose I should include the required libraries in it to be put in the Windows/System folder.I would not recommend putting anything in the Windows/System folder. You can really mess things up. What version are you going to install? 32 bit, 64 bit, and where? In System32 or in SysWOW64? And which version where? No, don't do that. If your program is 32 bit, just provide the 32 bit versions of the dll's in the executable directory. And if it's 64 bit, provide the 64 bit versions. Don't mix them. On Linux it's best to include dependencies and let the correct libraries install (otherwise you end up in a dependency hell). So, first things first, remove all the dll's from your exe directory (and if you installed openssl on Windows remove it there too so you begin with a clean slate). Then determine what you need. Where does your program fail. Copy the openssl 32 or 64 dlls to your exe directory (make sure you use the correct ones). And see then what errors you get. ---------------------------------------------------------------------- toby · 2023-09-09 16:33 why not save yourself a lot of headaches and just use synapse http://www.ararat.cz/synapse/doku.php/download i'm surprised rvk didn't suggst this to you ---------------------------------------------------------------------- maurobio · 2023-09-09 19:16 Hi, @toby! Quotewhy not save yourself a lot of headaches and just use synapse No, thanks! I do not have neither the time nor the inspiration to re- write my application to use Synapse (with which I am not familiar anyway).  Quotei'm surprised rvk didn't suggst this to you That's may be because he is too busy scolding me and calling me dumb (as if I don't know the difference between a 32-bit and a 64-bit system, etc.). Thank you! ---------------------------------------------------------------------- rvk · 2023-09-09 19:19 Quote from: maurobio on September 09, 2023, 09:16:53 pmThat's may be because he is too busy scalding me and calling me dumb (as if I don't know the difference between a 32-bit and a 64-bit system, etc.). I didn't call you dumb but that's the most common cause of your problem (besides you not defining exactly what the error message is). But if you don't want my help... Also fine. I also had some remarks/suggestions about your program but I think I'll keep them to myself now (if you think I was scolding you). ---------------------------------------------------------------------- maurobio · 2023-09-09 19:42 FYI: one cannot and should presume that someone does not know obvious things (like the fact that a 32-bit dll requires a 32-application, which BTW is my case - I have a 32-bit application which claims to not recognize 32-bit dll's which are installed with FPC/Lazarus, if they are put in the application folder). I have not much time nor patience for Windows (on which all sorts of stupid things can happen, except those you do expect), and would appreciate if someone provide me useful help with the Linux version, thank you. ---------------------------------------------------------------------- paweld · 2023-09-09 20:37 Hi @maurobio, @rvk asked a good question in my opinion, sometimes such obvious things (which are often overlooked) save a lot of time and nerves. e.g. I recently lost 2 days trying to fix a simple bug that wouldn't go away - the problem turned out to be that I was testing the old compilation (in the release version) all the time, and compiling the changes to the debug version - habit and fatigue lead to such stupid mistakes. My knowledge of Linux is not very good, but I know that it places great emphasis on security, so for a long time most distributions (as not all) use openssl v3. That's why your application doesn't want to work - fphttpclient in fpc 3.2 doesn't support this version of the library. So he recommends using one of the 3 suggestions you received: - upgrade fpc to trunk - openssl 3 support has been added. you probably won't have to make any changes to your code due to this change, but keep in mind that this is a development version and may cause problems - switching to synapse, which also supports openssl version 3. fphttpclient is very similar to synapse, so the change should not be so painful and labor-intensive. - using mormot2, which also supports openssl 3/3.1. here you will have to make some changes in the code. Well, and keep in mind that in 2 days support for openssl 1.1 ends - more about it wrote @abouchez: https://forum.lazarus.freepascal.org/in dex.php/topic,64539.msg490883.html#msg490883 ---------------------------------------------------------------------- TRon · 2023-09-09 20:46 Quote from: paweld on September 09, 2023, 10:37:01 pmMy knowledge of Linux is not very good, but I know that it places great emphasis on security, so for a long time most distributions (as not all) use openssl v3. Which is also why you should not distribute ssl libraries (or any other library for that matter) with a Linux application.  For TS: do not take my word for it. Instead go over to a Linux forum and ask the same question of how you can distribute ssl libraries with your Linux application and hopefully you are able to get out of that discussion alive and in one piece. ---------------------------------------------------------------------- maurobio · 2023-09-09 20:51 Hi, @paweld! Thank you very much for your kind and comprehensive answer. I will consider carefully the points you raised, especially the use of Synapse (as previously suggested by @toby). But I would like to know why is Synapse "better" and what makes it so, in comparison to the regular libraries provided with FPC. Does it no require OpenSSL? Also, I should clarify that in all my systems which have FPC/Lazarus installed, the applications runs as expected - the trouble arise in other machines, which do not have an installation of FPC/Lazarus (and therefore somehow lack one or more of the required libraries - I am not even sure of what they are really, because on at least a Linux installation which does have libssl installed, the application does not work). With best regards, ---------------------------------------------------------------------- maurobio · 2023-09-09 20:54 Hi, @TRon! Thank you very much for this suggestion, I will look into Linux forums in the hope of finding a solution to that. with warmest regards, ---------------------------------------------------------------------- TRon · 2023-09-09 21:04 @maurobio: Before actually doing so (I would not recommend it especially not on a Linux developers forum: they can be very harsh) try read this or do a search on/for (Linux) dependencies and try to understand how you are suppose to solve your issue on Linux. Quote from: maurobio on September 09, 2023, 10:51:21 pmI am not even sure of what they are really, because on at least a Linux installation which does have libssl installed, the application does not work). To make another (probably obvious) suggestion: try and do as much error checking as possible in your code, (double) checking each and every return value for validity and let your code act accordingly (for example display a message). Also try to run your application from a terminal (even if it is a GUI application) because especially with ssl there are some (FPC) error messages that are only displayed in the terminal when there is something wrong (and the exact error message could be very helpful in those cases). For debugging your applications under Linux that have dependency issues you can also use something like strace. ---------------------------------------------------------------------- toby · 2023-09-11 18:54 paweld : there is a 4th option - using curl with tprocess.execute( or sysutils.executeprocess( this would eliminate all his openssl problems and when openssl version 17.0.0.1 comes out with their quantum computer version he can wait until curl implements it - with no worries -- maurobio : in case you are still looking at your posting : the trunk/web code in https://github.com/maurobio/especies compiled on both my linux 32bit and 64bit systems with fpc-3.2.2 on them and my openssl version openssl version OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022) but gave different access violation errors when run - trunk/web   32bit linux e-Species e-Species

Error filling out form

Please enter a binomial specific epithet into the text box.

Remember: Only species are true natural entities!

Go back to the query form An unhandled exception occurred at $08060F31: EAccessViolation: Access violation   $08060F31   $0804C0F3  main,  line 641 of especies.pas GBIFSearch.Search(queryStr, key, scientificname, authorship, status, valid_name, kingdom, phylum, classe, order, family); --- trunk/web   64bit linux e-Species e-Species

Error filling out form

Please enter a binomial specific epithet into the text box.

Remember: Only species are true natural entities!

Go back to the query form

 

Classification from CoL

No names found

Text tags

You must supply content by using t he &text or &context querystring parameters,& nbsp;or by passing a URL, e.g. &url=exam ple.org/...

Wikipedia

No article title matches

Genomics from NCBI

TaxId: 0 No items found for

Map from GBIF

No species found

Images from Wikimedia Commons

An unhandled exception occurred at $0000000000408D1C: EAccessViolation: Access violation   $0000000000408D1C   $000000000040668D  main,  line 744 of especies.pas if imgs.Count = 0 then WriteLn('No images found')   --- i'm surprised that you invented a fight with rvk - probably the only person on this forum who was helping you with your actual code having him interested in helping you with your code was a wonderful thing for you - believe me --- so : did you try the fpc dev trunk? (make sure you don't overwrite your current installations of fpc and lazarus) after looking at your code - it seems you want to download all of wikipedia ... and then parse what you get for your data it looks to me that all you are changing is the url of what you are downloading this can be easily redone using curl from an array/tstringlist of urls - redoing your code to have curl get everything would be a real positive where are you putting the resulting data? a jsonfile ? a database? a text file? i didn't see where it was going once you get it --- ---------------------------------------------------------------------- maurobio · 2023-09-11 19:46 Hi, @toby! Thanks a lot for your detailed post and comments. But (as there is always a damned "but"!  ) your findings just contributed to raise my incredulity and blood pressure... My application has been developed using Lazarus 2.0.12, where it compiles and runs quite well, under Windows 10, Mint Linux 19 (32-bit) and  Lubuntu Linux 18 (64-bit). I am appalled to learn that it raises these strange errors when run in the trunk version of the IDE. This is just wasteful and exasperating! If you look more closely to the code of my application, you will see that it does not attempt to "download all of Wikipedia" - this would be patently absurd! As of Wikipedia, it just takes the first paragraph of text of the page referring to the searched species. As of the rest of the searched data, what the application does with them is to build a simple HTML page joining the pieces of information fetched from each source (GBIF, NCBI, Wikipedia, etc.) This is, I presume, what some used to call a "mashup". It implements the concept of "one web page for each living biological species", first presented by Professor Edward O. Wilson of Harvard in his article "The encyclopedia of life" (Trends in Ecology and Evolution, vol. 18, no. 2, Feb. 2003, pp. 77-80): QuoteImagine an electronic page for each species of organism on Earth, available everywhere by single access on command. The page contains the scientific name of the species, a pictorial or genomic presentation of the primary type specimen on which its name is based, and a summary of its diagnostic traits. The page opens out directly or by linking to other data bases, such as ARKive, Ecoport, GenBank and MORPHOBANK. It comprises a summary of everything known about the species’ genome, proteome, geographical distribution, phylogenetic position, habitat, ecological relationships and, not least, its practical importance for humanity. In fact, my application has been initially developed as a simple CGI application (https://github.com/maurobio/especies/tree/master/web), running on a webserver, but because of the issues with OpenSSL which did not allow it to run on a free hosting service, I decided to try and re-develop it a desktop application. That said, I did not "invent" a fight with mr. dvk (or anyone else for that matter). But I have sincerely tried to be polite and respectful with everyone here on this forum (of which I have been a member for more than five years now). I therefore cannot tolerate being treated with debauchery and disrespect. Anyone really willing to help should proceed just like you did: show me the errors and, objective suggestions to fix them. Thank you very much. With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-11 20:31 No fight here. Also no disrespect. But when someone wants to help, you sometimes need to explain things (like difference 32/64 bit, especially when that user suggest copying the dlls to the Windows directory which can lead to a crippled system). I can't help it if that person already know this (and could just say so). I wasn't scalding anyone. And I was not calling anyone dumb. Only the first sentence of my post could be a bit harsh ("lovely description of an error message"). But that was more my impatiens. Sorry for that. Sometimes a user just post "I have an error" without saying what error. Anyway, I did take the time to look briefly at the program last week and found that there is insufficient error handling for when there is a (correct) json retrieved without the expected values. Reading (accessing) those values/array index (while they are not there) will definitely lead to a crash in TGBIFSearch.Search. Since I couldn't find a description as to how to use the program (what to enter) I didn't look any further. ---------------------------------------------------------------------- maurobio · 2023-09-11 21:25 Hi, @rvk! QuoteOnly the first sentence of my post could be a bit harsh ("lovely description of an error message"). But that was more my impatiens. Sorry for that. Your apologies are much welcome, and fully accepted! Please also accepted mine. BTW, the reason I have not provided the full error message issued by Windows was that it is in Brazilian Portuguese (that's the language of my Windows installation), and I presume not many people can undertand that arcane idiom. I was just out if patience to translate it into my pidgin English. Notice that we were "fighting" around a Windows issue!  Nobody deserves that! QuoteSometimes a user just post "I have an error" without saying what error. I know what you mean, and do admit that this is a most irritating issue (like that brother OF it: "something does not work"). Thanks a lot for pointing out the problem with json in my code! I will take a full review of it, in an attempt to finding that (and hopefully other) such errors. You can test he code using the "Vicia faba" scientific name (that is the fava bean, very popular here down under  ). Thank you very much! With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-11 21:38 All good. Quote from: maurobio on September 11, 2023, 11:25:48 pmYou can test he code using the "Vicia faba" scientific name (that is the fava bean, very popular hear down under  ).I'll try that tomorrow (it's late here). I tried it with some kind of whale I found (which gave a json without some of the expected value). But I'll try some and give you my findings. (I did try in the IDE and I'm not sure anymore how the exception handling was set but I'll see tomorrow. I'll also try on Linux.) ---------------------------------------------------------------------- maurobio · 2023-09-11 21:56 Hi, @rvk! Thank you very much! With best regards, ---------------------------------------------------------------------- rvk · 2023-09-12 09:35 Ok, my preliminary findings (for now on Windows). I still have some remarks below about the error handling but it works correctly on Windows with the latest trunk and an older OpenSSL 1.0.2u. I can enter Vicia faba and it does all the communications and presents a page (see below). Although the image is a exclamation mark. Some remarks. I had a hard time in the beginning because I kept getting an access violation. It seems that the wiki page kept returning a 301 redirection on the final api call in Snippet. That isn't handled and results in a crash. I tried the URL in Curl and that worked (even with adding --http1.1 --tlsv1.2 --tls-max 1.2). I finally noticed I used Vicia faba on Curl but types vicia faba in the Windows app. It seems case sensitive  (Even though you do the WIKIPEDIA_REDIRECT_URL before WIKIPEDIA_URL, that URL doesn't do the redirection for case issues) And when passing vicia faba to the final api, you get a 301 redirect (which isn't handled). Adding a Client.AllowRedirect := true; below every TFPHttpClient.Create would fix that (you didn't add it everywhere). But... it's always wise to include some more exception handling. A website could be down and you want a graceful error then. Now it crashes in that case (even with the redirect line). Then for the other issue... invalid input. If I just type in a b as input (yeah, I know ), it crashes in TGBIFSearch.Search. That's because you expect ALL the keys to be there in the json. Here you should also add some error handling (is the key really in the json etc). Next... you do GetJson(Client.Get()). So you expect that Client.Get() always returns valid json. What if it doesn't? Either an exception handler or check for valid json could be wise here (GetJson gives an exception when it's passed non-valid json). Finally... when using Physeter macrocephalus I got some problems too but they are handled by the exception handler in TPubMedSearch.Search. Although I don't really understand why Client.Get sometimes failed for that request in fphttpclient, the exception is handled. Sidenote: In TPubMedSearch.Search I also see this (not sure if that's on other places too): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MemStrm := TMemoryStream.Create;XmlData := Client.Get(PUBMED_URL// some codeMemStrm.Free;If the Client.Get gives an exception, the MemStrm isn't released, so there is a memory leak. Always do the Create and then a try/finally to release the created item (that one probably got by you because you do at other places ) So on Windows it works correctly with just any older openssl dlls in the exe directory. For Linux it should work too (I'll test that when I get some time again, not sure if that's today though). The only issue on Linux could be the newer 1.1, 3.0 or 3.1 in the Linux distro. But as said before... openssl should be a requirement for the package itself so it installs automatically from distro. (How are you distributing? Via .deb? or something else?) Trunk will probably handle the newer 1.1/3 version but did you mention you wanted to keep this on Laz 2.0? In that case you would need to patch the openssl unit to load 1.1 or 3 version of openssl. Switching to release Lazarus (maybe with 'fixes') would be probably easier in that case. ---------------------------------------------------------------------- maurobio · 2023-09-12 21:41 Hi, @rvk! Thank you VERY MUCH for your comprehensive analysis of the many problems with my code. As a matter of fact, I was aware that my code has many loose knots, but your analysis found several more I have overlooked. Wikipedia uses those really dreadful redirections, but they provide means to handle them using the Wikipedia API itself - however, as your analysis have shown, it seems it is not performing as expected. The FPC/Lazarus networking units also have a mean of handle these redirections; in the end I mixed up both and the results was that messy code! I found the concept of using Curl really interesting; is there detailed documentation on how to use it? If the work required to convert my code to using it, I would consider change to Curl. What do you think? Would this be viable. Anyway, I will proceed with a through scanning of my code to find out and fix the loose points. More soon... With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-12 21:57 Quote from: maurobio on September 12, 2023, 11:41:11 pmI found the concept of using Curl really interesting; is there detailed documentation on how to use it? If the work required to convert my code to using it, I would consider change to Curl. What do you think? Would this be viable. What would be the upside to the requirement of curl being installed over the requirement of openssh being installed? Only upside would be that you don't need to update your code to use openssl 3. But curl is still a requirement because it's not standard installed on systems. Did you want to update your code to latest Lazarus? Then I don't see an upside to using curl package. You would also need to call curl with exec calls. Not my preference. Second downside.. you would need to use intermediate files for output (or use akward stdin/stdout stuff). With tfphttpclient you can work strictly in memory. I'll check out Linux tomorrow. What where your exact OS versions (and did you want to upgrade laz)? Those questions are important for investigating what is possible. ---------------------------------------------------------------------- maurobio · 2023-09-12 23:20 Hi, @rvk! QuoteWhat where your exact OS versions (and did you want to upgrade laz)? For the time being, I am using Lazarus 2.0.12 (32-bits) under Windows 10 (64-bits), Mint Linux 19.1 (32-bits) and Lubuntu 18.04 (64-bits). Frankly, I would not like to be obliged to upgrade these systems now, for lack of time and fear of breaking what is already working.  I really never imagined that these issues could also be related to the FPC/Lazarus version! Quoteyou would need to use intermediate files for output (or use akward stdin/stdout stuff). With tfphttpclient you can work strictly in memory. In earlier versions I have used temporary files for output, but dropped them in the current versions because memory files seemed to be more efficient. I don't understand why should temporary files be more efficient (and they may need administrative privileges). With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-13 07:39 Quote from: maurobio on September 13, 2023, 01:20:04 amFrankly, I would not like to be obliged to upgrade these systems now, for lack of time and fear of breaking what is already working.No, I didn't mean upgrading the OS, but upgrading to Lazarus 2.6. If you have problems with OpenSSL, that would be the easiest way I think. Quote from: maurobio on September 13, 2023, 01:20:04 amI really never imagined that these issues could also be related to the FPC/Lazarus version! What issues are you talking about exactly. Because I think those were never really discussed here. Do you mean installing OpenSSL for https access on those systems? Or do you have other problems? I just tried Especies (compiled with trunk) on a clean Mint 21 system (default installed OpenSSL 3.0.2) and it worked the same as on Windows. Quote from: maurobio on September 13, 2023, 01:20:04 amIn earlier versions I have used temporary files for output, but dropped them in the current versions because memory files seemed to be more efficient. I don't understand why should temporary files be more efficient (and they may need administrative privileges).No, just the other way around. Using intermediate (temporary) files is less efficient. But if you would use a system call with Curl then you might need to use those again. Or you would need to do something with stdin (catching output from a file). Besides... if temporary files could be restricted on a system, then calling an external program like Curl could also be restricted. Edit: BTW. I just tried it with Laz 2.0.12 (which includes FPC 3.2.0). It indeed doesn't support OpenSSL 3 but that's easily fixed (if you can recompile FPC yourself). You do need to recompile FPC because just recompiling Lazarus doesn't help (openssl.pas is part of FPC, not Lazarus). I'm not sure how to do that if you have a release Lazarus, I only do this from trunk and setting the version. fpcupdeluxe is probably the easiest way although I'm not sure if you can compile after you make changes, so you would need a version which has openssl 3. Maybe fixes_xx but perhaps someone else knows this. You can just add the ".3" to the DLLVersions array (like delphius already hinted at). I did this here and it works with Laz 2.0.12/FPC 3.2.0. For FPC 3.2.0 that would be (change the 17 to 18 and add the .3 before the 1.1): Code: [Select]  DLLVersions: array[1..18] of string = ('', '.3', '.1.1', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',                                         '.1.0.2', '.1.0.1','.1.0.0','.0.9.8',                                         '.0.9.7', '.0.9.6', '.0.9.5', '.0.9.4',                                         '.0.9.3', '.0.9.2', '.0.9.1'); But it's probably safe to just take the complete DLLVersions array from trunk (so other versions work too): Code: [Select]  DLLVersions: array[1..20] of AnsiString = ('', '.3', '.1.1', '.11', '.10', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',                                         '.1.0.2', '.1.0.1','.1.0.0','.0.9.8',                                         '.0.9.7', '.0.9.6', '.0.9.5', '.0.9.4',                                         '.0.9.3', '.0.9.2', '.0.9.1'); For Windows you can (for now) just add the 1.0.2 yourself as dll in the exe directory. I just checked Laz 2.2.6 (fpc 3.2.2). That one is still at 1.1 in the array so doesn't support openssl 3.0. You would need to make the same fix there too (or go for trunk). ---------------------------------------------------------------------- maurobio · 2023-09-13 11:31 Hi, @rvk! I am getting more and more confused!  QuoteWhat issues are you talking about exactly. Because I think those were never really discussed here.   Well, what about all the problems which you have pointed out yourself??? Or my initial problem, that was not having being able to run the application on any system which has not an installation of Lazarus??? QuoteDo you mean installing OpenSSL for https access on those systems? To begin with, I am not even sure that OpenSSL was the only problem with the application. QuoteOr do you have other problems? I still have the same problem I had from the start - namely, systems which do not have an installation of Lazarus seem unable to execute any search because of persistent "access violation" errors. But right now, two users complained about "access violation" errors even after they installed Lazarus on their systems (one running Windows 11, the other running Mint 21)!!!!  QuoteI just tried Especies (compiled with trunk) on a clean Mint 21 system (default installed OpenSSL 3.0.2) and it worked the same as on Windows. As I have told since the start of  this thread, I have the application working on Windows 10, Mint 19, and Lubuntu 18 without any problems! But all these systems have Lazarus (2.0.12) installed! One other point: you and other members of the forum have advised me to include exception checking into my code. But although I do not claim that such checks are complete, they are mostly there! See for example the 'Snippet' method in the class TGBIFSearch: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i constructor TGBIFSearch.Create;begin  GBIF_URL := 'http://api.gbif.org/v1';end; procedure TGBIFSearch.Search(const searchStr: string; var key: integer;  var scientificname, authorship, status, valid_name, kingdom, phylum,  classe, order, family: string);var  JsonData: TJsonData;  Client: TFPHttpClient;begin  try  Client := TFPHttpClient.Create(nil);    try      JsonData := GetJson(Client.Get(GBIF_URL + '/species/?name=' +        StringReplace(searchStr, ' ', '%20', [rfReplaceAll])));      key := JsonData.FindPath('results[0].key').AsInteger;      scientificname := JsonData.FindPath('results[0].canonicalName').AsString;      authorship := JsonData.FindPath('results[0].authorship').AsString;    status := JsonData.FindPath('results[0].taxonomicStatus').AsString;    status := LowerCase(StringReplace(status, '_', ' ', [rfReplaceAll]));      if status <> 'accepted' then        valid_name := JsonData.FindPath('results[0].species').AsString;      kingdom := JsonData.FindPath('results[0].kingdom').AsString;      phylum := JsonData.FindPath('results[0].phylum').AsString;      classe := JsonData.FindPath('results[0].class').AsString;      order := JsonData.FindPath('results[0].order').AsString;      family := JsonData.Findpath('results[0].family').AsString;    except      key := 0;      scientificname := '';      authorship := '';      status := '';      valid_name := '';      kingdom := '';      phylum := '';    classe := '';      order := '';      family := '';    end;  finally  JsonData.Free;    Client.Free;  end;end;       This code may not be exactly beautiful, but it should take care of errors in the returning jason data. Or shouldn't it? All the other search classes used by the application also have similar exception treatment (even if it can be improved here or there). I am at a loss...  With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-13 11:52 Quote from: maurobio on September 13, 2023, 01:31:26 pm Well, what about all the problems which you have pointed out yourself??? Or my initial problem, that was not having being able to run the application on any system which has not an installation of Lazarus???I'm also puzzled by that. I tried a compiled version of your program om a fresh Mint 21 (without Lazarus or FPC) and it worked fine (with the openssl 3 fix included because I compiled with trunk and my mint 21 has OpenSSL 3). Quote from: maurobio on September 13, 2023, 01:31:26 pmQuoteDo you mean installing OpenSSL for https access on those systems?To begin with, I am not even sure that OpenSSL was the only problem with the application.Well, it was for me I didn't have any other problems on a fresh system (other than crashing when entering something invalid). So I don't see any other problem than OpenSSL. Quote from: maurobio on September 13, 2023, 01:31:26 pmQuoteOr do you have other problems?I still have the same problem I had from the start - namely, systems which do not have an installation of Lazarus seem unable to execute any search because of persistent "access violation" errors. But right now, two users complained about "access violation" errors even after they installed Lazarus on their systems (one running Windows 11, the other running Mint 21)!!!!  The access violation is due to the fact OpenSSL 3 is installed on most systems (at least it was for me). And your Lazarus 2.0.12/FPC 3.2.0 doesn't do OpenSSL 3. That's really the only problem I could find. Quote from: maurobio on September 13, 2023, 01:31:26 pmAs I have told since the start of  this thread, I have the application working on Windows 10, Mint 19, and Lubuntu 18 without any problems! But all these systems have Lazarus (2.0.12) installed!And they also probably have OpenSSL 1.0.2 installed (or lower). You can check that with openssl version. What is your version on those systems? And what is it on the problem systems? Quote from: maurobio on September 13, 2023, 01:31:26 pmOne other point: you and other members of the forum have advised me to include exception checking into my code. But although I do not claim that such checks are complete, they are mostly there! See for example the 'Snippet' method in the class TGBIFSearch:Sorry, my apologies. You are correct. I'm not sure why my version crashed with invalid data, but now it does seem to work correctly. (I don't know how I could overlook your except structure in GBIFSearch  ) Quote from: maurobio on September 13, 2023, 01:31:26 pmThis code may not be exactly beautiful, but it should take care of errors in the returning jason data. Or shouldn't it? If it works and is stable, there's nothing wrong with that ---------------------------------------------------------------------- maurobio · 2023-09-13 12:32 Hi, @rvk! Now, I breath a sign of relief!  As I (finally) do understand it, the problem is really with OpenSSL (other than comparatively minor issues with some still unhandled exceptions). So, I ask your advice on how to best proceed regarding OpenSSL. Under Windows, should it suffice to include it in the distribution package? In this case, what should be the correct version to be included (1.x or 3.x)? Under Linux (whatever distro) should OpenSSL be added as a dependence in the Debian package used to distribute the application? The matter of the Lazarus version versus the OpenSSL version is still not clear to me. Of course, I will also check carefully the exception handling and add it at some points where it is clearly deficient. Thank you very much! With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-13 13:29 Quote from: maurobio on September 13, 2023, 02:32:13 pmUnder Windows, should it suffice to include it in the distribution package?I assume security isn't really a big deal for communicating with that server (you don't transfer sensitive information). So you could just use a fairly recent version which is still supported. I don't think the 1.1 family is supported in FPC 3.2.0 so you would need the latest 1.0.2. (I think that's 1.0.2zi. But 1.0.2u from fulgan would be fine too.) Quote from: maurobio on September 13, 2023, 02:32:13 pmUnder Linux (whatever distro) should OpenSSL be added as a dependence in the Debian package used to distribute the application?Yes, and your dependency would be the smallest version you support, which is 1.0.2 in that case. But... you need to support higher versions too because a dependency won't downgrade a higher version. (it could if you set it at exactly that level but that could just prevent your program from installing.) For example: Code: [Select]Depends: openssl >= 1.0.2kI'm not an Linux expert so I'm not sure how that's done exactly. But you will still need to support OpenSSL 3 if it's installed and that's the hard part. You would need to recompile FPC 3.2.0 (as stated in my previous post). There might be a possibility to use 1.0.2 on newer systems, but I haven't looked into that. (for example search for multiple openssl linux) As far as I could see the instructions for that are downloading openssl 1.0.2 source and compiling with install to custom directory. After that your program would need to adjust the search path to let it find those older libraries. I'm not sure if that's the best way to go. Maybe someone with more Linux knowledge can give some more info about this? ---------------------------------------------------------------------- maurobio · 2023-09-13 13:51 Hi, @rvk! OK, I downloaded OpenSSL 1.0.2u for Windows from here: https://indy.fulgan.com/SSL/ The distribution package is a zip archive containing the following files: Hashinfo.txt ReadMe.txt OpenSSLLicense.txt openssl.exe libeay32.dll ssleay32.dll Should it be enough to include just the two DDL's in my installation package for Windows? As of Linux, if I include OpenSSL 2.0.1 in the list of dependencies, will that version be used instead of OpenSSL 3.x (even if the latter is also installed)? Alternatively, should it be better to upgrade Lazarus (both in Windows and Linux) to the latest (but not necessarily the trunk) version if this version offers consistent support for OpenSSL 3 in all platforms? Thanks a lot! With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-13 14:47 BTW. You didn't handle all exception. Yes, you have except almost everywhere but if it was everywhere you wouldn't get that access violation (because that's also an except). If you handle the except in Snippet with a Showmessage you get image below this post. But you return Result := '' with that exception. And further on in the program, it can't handle that Result = '' and gives an access violation. I'm not sure where but for that you would need to debug (with setting result to '' for example). Quote from: maurobio on September 13, 2023, 03:51:16 pmShould it be enough to include just the two DDL's in my installation package for Windows?Yes, that should be enough. Quote from: maurobio on September 13, 2023, 03:51:16 pmAs of Linux, if I include OpenSSL 2.0.1 in the list of dependencies, will that version be used instead of OpenSSL 3.x (even if the latter is also installed)?(you mean 1.0.2 ) No, if you include that as >= dependencies it makes sure that's the minimum version installed. So with >= 1.0.2 and 3 being already installed it will do nothing. But your program would need to handle the 3 version (because there is no 1.0.2). But if you define it as = 1.0.2 then it needs to be that version exactly. I'm not sure if it will try to downgrade to 1.0.2 but I can guarantee you that you'll end up in a dependency hell. Because openssl has a dependency on libc6 and libcrypto. So they also need to be downgraded. And lots of other packages are again dependend on libc6 and openssl 3 so you end up in a loop. Quote from: maurobio on September 13, 2023, 03:51:16 pmAlternatively, should it be better to upgrade Lazarus (both in Windows and Linux) to the latest (but not necessarily the trunk) version if this version offers consistent support for OpenSSL 3 in all platforms?I think I saw the '.1.1' in the array for FPC 3.2.0 so OpenSSL 1.1 should be supported. But if you want OpenSSL 3 support... I think it's only in trunk (because I have a Lazarus 2.2.6 here with FPC 3.2.2 which only has .1.1). BTW. That was probably also the reason Synapse came up. It can use the openssl 3 without completely recompiling FPC. But then you would need to re-program all your communications. Does anybody know how to "hack" the openssl.pas for loading OpenSSL 3 without recompiling FPC???? For changing the constant for DLLVersions before InitSSLInterface? I did this now and it seems to go a step further but still crashes with the access violation. But maybe if you build in the exception check at the right places with a showmessage of what kind of exception (instead of just return), you can find the problem. This somewhere before the first call to a https get. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i openssl.DLLVersions[1] := '.3';BTW, this is a hack because it replaces the .1.1. You might want to insert it on position 2 instead of replacing it. EDIT: That hack does work but there is some trouble/instability further on (I think in Wikimedia Commons). ---------------------------------------------------------------------- rvk · 2023-09-13 15:01 This will probably the safest option: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  openssl.DLLVersions[Length(openssl.DLLVersions) - 1] := '.3'; It will replace support for OpenSSL 0.9.1 into OpenSSL 3  (That version should exists anymore anyway.) Works on my Mint 21 system. On my development system I still get some problems but there I'm running in the IDE. ---------------------------------------------------------------------- maurobio · 2023-09-13 15:09 Hi, @rvk! At lunch right now but I could not make you wait for my reply! That's what mobile devices are for!  As of Wikipedia, I will entirely replace its redirection handling with that provided with Lazarus networking library, which is simpler and probably safer. I will try the Windows version first and then Linux. Will report my results later. Thank you very much! With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-13 15:50 Quote from: maurobio on September 13, 2023, 05:09:12 pmAs of Wikipedia, I will entirely replace its redirection handling with that provided with Lazarus networking library, which is simpler and probably safer.O, I thought that WIKIPEDIA_REDIRECT_URL was for handling other kinds of redirections too. For when you make a common typo or redirect to a similar name? But if that's also handled though a 301 then it's not needed. ---------------------------------------------------------------------- rvk · 2023-09-13 17:38 I forgot to include the image from when you show the exception instead of just silently returning. You need to determine if the exception is expected or unexpected. Expected exception can be handled silently (because you handle them correctly). Unexpected exceptions (like no OpenSSL installed) would benefit from a more clear message. ---------------------------------------------------------------------- paweld · 2023-09-13 18:28 Hi @maurobio,  I made several changes to your application, including replacing network components with synapse, moving data retrieval to a thread, fixing memory leaks: https://github.com/paweld/especies    It should work on Linux, you just need to install libssl-dev.    Required components: synapse (trunk version) and bgrabitmap          Tested on lazarus trunk and fpc 3.2-fixes ---------------------------------------------------------------------- maurobio · 2023-09-13 20:30 Hi, @rvk! QuoteO, I thought that WIKIPEDIA_REDIRECT_URL was for handling other kinds of redirections too. As far as I know, the Wikipedia redirect mechanism is for redirecting pages; in the case of my application, it should direct the Latin scientific name Loxodonta africana to the common English name "African bush elephant". I cannot say if this redirecting mechanism also works with pages which don't exist. QuoteUnexpected exceptions (like no OpenSSL installed) would benefit from a more clear message. Fine, but where exactly in the code have you put the exception handler which generated that message? With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-13 20:35 Quote from: maurobio on September 13, 2023, 10:30:58 pmFine, but where exactly in the code have you put the exception handler which generated that message? I put that in the except in the function Search (where the first openssl call tales place). You have a result := '' and I added a showmessage. You could also set a variable and handle it in a higher level. You should follow the result because a result of '' will give an access violation further on in the program. ---------------------------------------------------------------------- maurobio · 2023-09-13 20:43 Hi, @paweld!!! QuoteI made several changes to your application, including replacing network components with synapse, moving data retrieval to a thread, fixing memory leaks: Man, what an incredible feat!! Frankly, I am at a loss of words, in my poor pidgin English, even in my native Portuguese, to praise and tank you and @rvk enough for your invaluable help in making true Professor's E. O. Wilson dream of "one webpage for each species"! You fully deserve a place among the true heroes of biodiversity conservation (who are not those who just speak but do nothing to save the species which share this planet with us and which have as many right to live here as ourselves). As also does Florian Klaempf and all other developers of this absolutely great tool which is Free Pascal/Lazarus! I will try your Synapse-enhanced version ASAP. With warmest regards, muitas felicidades! ---------------------------------------------------------------------- toby · 2023-09-13 21:20 geez paweld that was amazing https://github.com/paweld/especies    you and rvk are truly amazing maurobio better hope that boss doesn't know about this forum ---------------------------------------------------------------------- maurobio · 2023-09-13 23:39 Hi, @gentlemen! Just a brief report of my progress so far: I installed synapse40 and bgrabitmap-11.5.5 and have been able to compile and run @paweld code under Windows 10 without hassle. I have not yet tested it in a Windows machine which has no Lazarus installed. I also have not yet tried to compile it and run under Linux. It will take me some time to peruse the modified code, but it looks nice and I don't intend to modify anything (except perhaps for some cosmetic touches here and there; I will also add special acknowledgments to you all wizards into the "About" dialog box). But (there is always a "but"  ) I have a doubt concerning the external libraries required by Synapse. According to the page at the Lazarus wiki, QuoteSynapse offers serial port and TCP/IP connectivity. It differs from other libraries that you only require to add some Synapse Pascal source code files to your code; no need for installing packages etc. The only exception is that you will need an external crypto library if you want to use encryption such as SSL/TLS/SSH. Is this crypto library required? And what about OpenSSL? As I did understand (and of course I may have misunderstood it), OpenSSL is supported, QuoteYou can use OpenSSL, CryptLib, StreamSecII or OpenStreamSecII SSL support with Synapse. By default, no SSL support is used. The support is activated by putting the chosen unit name in the uses section in your project. You also have to put the binary library file in your project path (Windows), or install it into your library search path (Linux, macOS, FreeBSD). As of "the binary library file" do it refer to the same libraries (libeay32.dll, ssleay32.dll in the case of Windows) which are also required by the regular FPC networking routines? I am still a little but confused as to what the exactly external libraries I should include into the distribution packages (or list of dependencies in the case of Linux). @paweld wrote that, QuoteIt should work on Linux, you just need to install libssl-dev.  Is that all? With warmest regards, ---------------------------------------------------------------------- paweld · 2023-09-14 07:41 QuoteAnd what about OpenSSL?QuoteAs of "the binary library file" do it refer to the same libraries (libeay32.dll, ssleay32.dll in the case of Windows) which are also required by the regular FPC networking routines? I am still a little but confused as to what the exactly external libraries I should include into the distribution packages (or list of dependencies in the case of Linux)openssl must be present on the system: in windows there must be openssl libraries (dll in version 1.0 or 1.1 or 3.0  ) and in linux it must be installed (most distributions as not all have it installed by default)        QuoteIs that all?on my test environment this was enough - I installed a fresh Debian 12 in VirtualBox and just installed libssl-dev and the program runs without any problems ---------------------------------------------------------------------- rvk · 2023-09-14 07:41 I just tried the paweld version under Windows (great work  ) Installing the BGRA in trunk gave problems because in OPM there is still an older version. Using the dev version fixed that. (BTW I also had a problem installing HTMLViewer in trunk because of 2 if statements/and not having (). ) Some remarks: *) When compiling the program in the dtp directory, it might be better to automatically let the compiler put the .exe one directory above (via options). Because the exe needs the static directory it needs to be there anyway. So compiling directory to one directory higher is the best way. *) When not putting the OpenSSL dll's in the exe directory I didn't get an error message, but the results were non-specific. It might be better to handle that exception (in the first call) somewhat better and show that OpenSSL is missing. Or if there is an exception in the first call, you could add a big red message in the view, stating what's wrong. ("OpenSSL is missing", "You entered an invalid species", etc etc) Even if you copy the OpenSSL dll's with the exe, it's always best to expect the unexpected *) When running outside the IDE, I did get an exception when clicking on an image. QuoteCan't locate 'xxx\especies\http:\en.wikipedia.org\wiki\File:Broad-beans-after- cooking.jpg'. *) When running in the IDE, then of course there are the multiple exceptions (which are handled but the IDE shows them anyway because you are in debugging mode). For Vicia faba for example I get an exception in the IDE. Now, the exception are handled... but... in some case it might be better to avoid the exceptions entirely. For example... if you have this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Result1 := EvaluateXPathExpression('//Article/ArticleTitle', Doc.DocumentElement);    Result2 := EvaluateXPathExpression('//PubmedD ata/ArticleIdList/ArticleId[@IdType="doi"]', Doc.DocumentElement);    NodeSet1 := Result1.AsNodeSet;    NodeSet2 := Result2.AsNodeSet;    if NodeSet1.Count > 0 then    begin      for i := 0 to NodeSet1.Count - 1 do      try        references.Add(TDomElement(NodeSet1.Items[i]).TextContent + '=' + TDomElement(NodeSet2.Items[i]).TextContent);      except        continue;      end;    end;When Result2 has less nodes you will end up in the exception. But... that's not 'nice' or best practice. It would be better to check if the element exists before accessing it. A simple line like this will fix that: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Result1 := EvaluateXPathExpression('//Article/ArticleTitle', Doc.DocumentElement);    Result2 := EvaluateXPathExpression('//PubmedD ata/ArticleIdList/ArticleId[@IdType="doi"]', Doc.DocumentElement);    NodeSet1 := Result1.AsNodeSet;    NodeSet2 := Result2.AsNodeSet;    if NodeSet1.Count > 0 then    begin      for i := 0 to NodeSet1.Count - 1 do      try        if i <= NodeSet2.Count - 1 then          references.Add(TDomElement(NodeSet1.Items[i]).TextContent + '=' + TDomElement(NodeSet2.Items[i]).TextContent);      except        continue;      end;    end; You can leave the exception for when you get something really unexpected. But you SHOULD handle an excepted exception better than just letting it happen. There are a few of these constructs. Quote from: maurobio on September 14, 2023, 01:39:17 amBut (there is always a "but"  ) I have a doubt concerning the external libraries required by Synapse. According to the page at the Lazarus wiki,Synapse doesn't have any more requirements than the openssl from FPC. In fact... if you look at the openssl.pas from FPC you'll see it comes from Synapse Quote from: maurobio on September 14, 2023, 01:39:17 amIs this crypto library required? And what about OpenSSL? As I did understand (and of course I may have misunderstood it), OpenSSL is supported,The libcrypto is not needed for 1.0.2. You can see that in the CryptoLibNames in ssl_openssl_lib. Only for OpenSSL 3 and 1.1 the libcrypto is needed. Maybe for some clarity (needed dlls): OpenSSL 1.0.2 = libeay32.dll and ssleay32.dll OpenSSL 1.1.1 = libssl-1_1.dll and libcrypto-1_1.dll (NOTE: -x64 appended for 64 bit version) OpenSSL 3.x.x = libssl-3.dll and libcrypto-3.dll        (NOTE: -x64 appended for 64 bit version) See downloads at https://wiki.overbyte.eu/wiki/index.php/ICS_Download ---------------------------------------------------------------------- rvk · 2023-09-14 08:26 Quote from: paweld on September 14, 2023, 09:41:31 amQuoteIs that all?on my test environment this was enough - I installed a fresh Debian 12 in VirtualBox and just installed libssl-dev and the program runs without any problems libssl-dev includes only header files. It doesn't actually include the openssl library. But because of dependency it will probably install the library itself too. But for a clean system, libssl-dev shouldn't be needed. Just the libssl would be sufficient for the executable. (For a development system with Lazarus you will want the headers.) This is what the libssl-dev includes. Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i :~ $ sudo apt-file list libssl-devlibssl-dev: /usr/include/aarch64-linux- gnu/openssl/opensslconf.hlibssl-dev: /usr/include/openssl/aes.hlibssl- dev: /usr/include/openssl/asn1.hlibssl-dev: /usr/include/openssl/asn1_mac.hlibssl-dev: /usr/include/openssl/asn1err.hlibssl-dev: /usr/include/openssl/asn1t.hlibssl-dev: /usr/include/openssl/async.hlibssl-dev: /usr/include/openssl/asyncerr.hlibssl-dev: /usr/include/openssl/bio.hlibssl-dev: /usr/include/openssl/bioerr.hlibssl-dev: /usr/include/openssl/blowfish.hlibssl-dev: /usr/include/openssl/bn.hlibssl-dev: /usr/include/openssl/bnerr.hlibssl-dev: /usr/include/openssl/buffer.hlibssl-dev: /usr/include/openssl/buffererr.hlibssl-dev: /usr/include/openssl/camellia.hlibssl-dev: /usr/include/openssl/cast.hlibssl-dev: /usr/include/openssl/cmac.hlibssl-dev: /usr/include/openssl/cms.hlibssl-dev: /usr/include/openssl/cmserr.hlibssl-dev: /usr/include/openssl/comp.hlibssl-dev: /usr/include/openssl/comperr.hlibssl-dev: /usr/include/openssl/conf.hlibssl-dev: /usr/include/openssl/conf_api.hlibssl-dev: /usr/include/openssl/conferr.hlibssl-dev: /usr/include/openssl/crypto.hlibssl-dev: /usr/include/openssl/cryptoerr.hlibssl-dev: /usr/include/openssl/ct.hlibssl-dev: /usr/include/openssl/cterr.hlibssl-dev: /usr/include/openssl/des.hlibssl-dev: /usr/include/openssl/dh.hlibssl- dev: /usr/include/openssl/dherr.hlibssl-dev: /usr/include/openssl/dsa.hlibssl-dev: /usr/include/openssl/dsaerr.hlibssl-dev: /usr/include/openssl/dtls1.hlibssl-dev: /usr/include/openssl/e_os2.hlibssl-dev: /usr/include/openssl/ebcdic.hlibssl-dev: /usr/include/openssl/ec.hlibssl-dev: /usr/include/openssl/ecdh.hlibssl-dev: /usr/include/openssl/ecdsa.hlibssl-dev: /usr/include/openssl/ecerr.hlibssl-dev: /usr/include/openssl/engine.hlibssl-dev: /usr/include/openssl/engineerr.hlibssl-dev: /usr/include/openssl/err.hlibssl-dev: /usr/include/openssl/evp.hlibssl-dev: /usr/include/openssl/evperr.hlibssl-dev: /usr/include/openssl/hmac.hlibssl-dev: /usr/include/openssl/idea.hlibssl-dev: /usr/include/openssl/kdf.hlibssl-dev: /usr/include/openssl/kdferr.hlibssl-dev: /usr/include/openssl/lhash.hlibssl-dev: /usr/include/openssl/md2.hlibssl-dev: /usr/include/openssl/md4.hlibssl-dev: /usr/include/openssl/md5.hlibssl-dev: /usr/include/openssl/mdc2.hlibssl-dev: /usr/include/openssl/modes.hlibssl-dev: /usr/include/openssl/obj_mac.hlibssl-dev: /usr/include/openssl/objects.hlibssl-dev: /usr/include/openssl/objectserr.hlibssl-dev: /usr/include/openssl/ocsp.hlibssl-dev: /usr/include/openssl/ocsperr.hlibssl-dev: /usr/include/openssl/opensslv.hlibssl-dev: /usr/include/openssl/ossl_typ.hlibssl-dev: /usr/include/openssl/pem.hlibssl-dev: /usr/include/openssl/pem2.hlibssl-dev: /usr/include/openssl/pemerr.hlibssl-dev: /usr/include/openssl/pkcs12.hlibssl-dev: /usr/include/openssl/pkcs12err.hlibssl-dev: /usr/include/openssl/pkcs7.hlibssl-dev: /usr/include/openssl/pkcs7err.hlibssl-dev: /usr/include/openssl/rand.hlibssl-dev: /usr/include/openssl/rand_drbg.hlibssl-dev: /usr/include/openssl/randerr.hlibssl-dev: /usr/include/openssl/rc2.hlibssl-dev: /usr/include/openssl/rc4.hlibssl-dev: /usr/include/openssl/rc5.hlibssl-dev: /usr/include/openssl/ripemd.hlibssl-dev: /usr/include/openssl/rsa.hlibssl-dev: /usr/include/openssl/rsaerr.hlibssl-dev: /usr/include/openssl/safestack.hlibssl-dev: /usr/include/openssl/seed.hlibssl-dev: /usr/include/openssl/sha.hlibssl-dev: /usr/include/openssl/srp.hlibssl-dev: /usr/include/openssl/srtp.hlibssl-dev: /usr/include/openssl/ssl.hlibssl-dev: /usr/include/openssl/ssl2.hlibssl-dev: /usr/include/openssl/ssl3.hlibssl-dev: /usr/include/openssl/sslerr.hlibssl-dev: /usr/include/openssl/stack.hlibssl-dev: /usr/include/openssl/store.hlibssl-dev: /usr/include/openssl/storeerr.hlibssl-dev: /usr/include/openssl/symhacks.hlibssl-dev: /usr/include/openssl/tls1.hlibssl-dev: /usr/include/openssl/ts.hlibssl-dev: /usr/include/openssl/tserr.hlibssl-dev: /usr/include/openssl/txt_db.hlibssl-dev: /usr/include/openssl/ui.hlibssl-dev: /usr/include/openssl/uierr.hlibssl-dev: /usr/include/openssl/whrlpool.hlibssl-dev: /usr/include/openssl/x509.hlibssl-dev: /usr/include/openssl/x509_vfy.hlibssl-dev: /usr/include/openssl/x509err.hlibssl-dev: /usr/include/openssl/x509v3.hlibssl-dev: /usr/include/openssl/x509v3err.hlibssl-dev: /usr/lib/aarch64-linux- gnu/libcrypto.alibssl-dev: /usr/lib/aarch64-linux- gnu/libcrypto.solibssl-dev: /usr/lib/aarch64-linux-gnu/libssl.alibssl- dev: /usr/lib/aarch64-linux-gnu/libssl.solibssl-dev: /usr/lib/aarch64-linux-gnu/pkgconfig/libcrypto.pclibssl-dev: /usr/lib/aarch64-linux-gnu/pkgconfig/libssl.pclibssl-dev: /usr/lib/aarch64-linux-gnu/pkgconfig/openssl.pclibssl-dev: /usr/share/doc/libssl-dev/changelog.Debian.gzlibssl-dev: /usr/share/doc/libssl-dev/changelog.gzlibssl-dev: /usr/share/doc/libssl-dev/copyright In the "depends" you see that libssl1.1 will be needed and installed if needed: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i :~ $ sudo apt-cache depends libssl-devlibssl-dev  Depends: libssl1.1  Conflicts:   Suggests: libssl-doc BTW. You will also be safe to install openssl package because that one also depends on libssl. Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i :~ $ sudo apt-cache depends opensslopenssl  Depends: libc6  Depends: libssl1.1  Suggests: ca-certificatesAnd I think you may want the openssl executable over the headers on a clean non-development system ---------------------------------------------------------------------- maurobio · 2023-09-14 13:18 Hi, @paweld, @rvk! Many thanks for these other good suggestions, I will add some changes to the code to conform to your suggestions. @rvk pointed out a small detail which may explain why I didn't have errors, but users who attempted to run the executable program had - it has not occurred to me that such errors (for unknown reasons to me) did not appeared when the program was running in the IDE (and I have been too imprudent to not try it outside the development environment, as a regular user would do)!  Just as an aside, I have no problems compiling the latest release version (not the trunk version) of BGRA library. Anyway, I never use OPM to install libraries - I prefer to download the latest release files and install using the IDE package manager. Also, the program also ran fine with the last (very old) release version of Synapse (4.0). With warmest regards, ---------------------------------------------------------------------- paweld · 2023-09-14 13:36 Quote from: rvklibssl-dev includes only header files. It doesn't actually include the openssl library. But because of dependency it will probably install the library itself too. Thank you for the information, i didn't know about that Quote from: maurobioAlso, the program also ran fine with the last (very old) release version of Synapse (4.0) old version of synapse (40, stable) does not support openssl 3 ---------------------------------------------------------------------- maurobio · 2023-09-14 13:51 Hi, @paweld! Quoteold version of synapse (40, stable) does not support openssl 3 I am using OpenSSL 1.0.2 as per @rvk suggestion. Best regards, ---------------------------------------------------------------------- maurobio · 2023-09-14 14:01 Hi, gentlemen! I have some further progress to report. I have just tried the program on an older Windows 7 machine without Lazarus installed. I just copied the executable (created with Lazarus 2.0.12 on a newer Windows 10 machine),  the two OpenSSL dll's (ssleay32.dll and libeay32.dll), and the "static" folder to the same folder and voilà! The program ran smoothly with all species I entered (Vicia faba, Loxodonta africana, Physeter catodon). It even ran without errors when I entered a non-existent species ("Loxodota africana", which was a typo, notice the missing "n" in the genus name). This test was done with the original  code improved by @paweld, without the further error checking just suggested by @rvk and that I will add to the code soon. This afternoon I will proceed with the tests, this time under three Linux distros. More soon... With warmest regards, ---------------------------------------------------------------------- paweld · 2023-09-14 15:00 Quote from: rvkBut for a clean system, libssl-dev shouldn't be needed. Just the libssl would be sufficient for the executable.I just now checked on a freshly installed system (Debian 12). After the installation I have openssl version 3.0.9, but the program does not download over https. Only installing the libssl-dev package (also version 3.0.9) makes all the data downloaded.    Uninstalling the package makes it fail again over https.        Quote from: maurobioI am using OpenSSL 1.0.2 as per @rvk suggestion.on linux as I mentioned earlier the default is openssl version 3, so using the old version of synapse will not work with the openssl package installed ---------------------------------------------------------------------- delphius · 2023-09-14 16:12 Quote from: paweld on September 14, 2023, 05:00:48 pmon linux as I mentioned earlier the default is openssl version 3, so using the old version of synapse will not work with the openssl package installed Please, pros, explain to me why, when developing Free Pascal or Lazarus programs, we must necessarily rely on intermediary libraries like LNet, Indy, Synapse, etc.? Why is it impossible to work with OpenSSL directly, as tfphttpclient does? How will such code from the example working with OpenSSL over simple sockets directly be worse? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program opensslmail; {$mode objfpc}{$H+}{$Packrecords C} uses  SysUtils, sockets, resolve, openssl; type  PSSL_CIPHER = ^SSL_CIPHER;  // https: //github.com/openssl/openssl/blob/ed4a71d18d939f557b430c4369d118b55c1c 0b6c/ssl/ssl_local.h#L397  SSL_CIPHER = record    valid: LongWord;    name: PChar;    stdname: PChar;    id: packed array[0..1] of Char;    algorithm_mkey: LongWord;    algorithm_auth: LongWord;    algorithm_enc: LongWord;    algorithm_mac: LongWord;    min_tls: Integer;    max_tls: Integer;    min_dtls: Integer;    max_dtls: Integer;    algo_strength: LongWord;    algorithm2: LongWord;    strength_bits: LongInt;    alg_bits: LongWord;  end; const  // The read functions work based on the SSL/TLS records. The data are received in records (with a maximum record size of 16kB)  // For TLS 1.2 and earlier, that limit is 2^14 octets. TLS 1.3 uses a limit of 2^14+1 octets.  // https://www.rfc- editor.org/rfc/rfc8449.html#section-4  BUF_SIZE = 16 * 1024;   Host = 'example.org';  Port = 443;   {$IFDEF WINDOWS}  ext = '.dll';  {$ELSE}  ext = '.so';  {$ENDIF} var  filepath, trustedCertFile: string;  //OpenSSL  ctx: PSSL_CTX;  ssl: PSSL;  cipherPtr: PSSL_CIPHER;  server_cert:pX509;  in_buf: array[0..BUF_SIZE - 1] of char;  request: string;  nbytes_written, nbytes_read, ssl_error: integer;  cert_str: AnsiString;  tempBuf: AnsiString;  //Sockets  CSocket: TSocket;  Address: TInetSockAddr;  IPAddr: string;  hrs: THostResolver; procedure PrintSSLCipherInfo(const cipher: SSL_CIPHER);begin  Writeln('Cipher Name: ', cipher.name);  Writeln('RFC Name: ', cipher.stdname);  // https://www.iana.org/assignments/tls-parameters/tls- parameters.xhtml#tls-parameters-4  Writeln('TLS Cipher ID: ', '0x' + IntToHex(Ord(cipher.id[1]), 2) + ', 0x' + IntToHex(Ord(cipher.id[0]), 2));  Writeln('Key Exchange Algorithm: ', cipher.algorithm_mkey);  Writeln('Server Authentication Algorithm: ', cipher.algorithm_auth);  Writeln('Symmetric Encryption Algorithm: ', cipher.algorithm_enc);  Writeln('Symmetric Authentication Algorithm: ', cipher.algorithm_mac);  Writeln('Minimum SSL/TLS Protocol Version: ', cipher.min_tls);  Writeln('Maximum SSL/TLS Protocol Version: ', cipher.max_tls);  Writeln('Minimum DTLS Protocol Version: ', cipher.min_dtls);  Writeln('Maximum DTLS Protocol Version: ', cipher.max_dtls);  Writeln('Strength and Export Flags: ', cipher.algo_strength);  Writeln('Extra Flags: ', cipher.algorithm2);  Writeln('Number of Bits Used: ', cipher.strength_bits);  Writeln('Number of Bits for Algorithm: ', cipher.alg_bits);end; begin  filepath := ExtractFilePath(ParamStr(0));  // https://curl.se/ca/cacert.pem  trustedCertFile := filepath + 'cacert.pem';  // Load OpenSSL dynamic libraries from program folder  InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext);   // Show libs version https://github.com/openssl/openssl/blob/8 f51b2279eda1e0cffb3400c2e5b5c3771f62ea7/include/openssl/crypto.h.in#L1 62  WriteLn('OpenSSL version: ' + OpenSSLGetVersion(7)); // OPENSSL_FULL_VERSION_STRING    // Create an SSL context.  ctx := SSLCTXnew(SslTLSMethod);  if not Assigned(ctx) then  begin    WriteLn('Could not create SSL context');    Halt(1);  end;   // Load trusted certificates.  if SSLCTXloadverifylocations(ctx, PChar(trustedCertFile), '') <= 0 then    begin      WriteLn('Could not load trusted certificates');      Halt(1);    end;   // Set verification options.  SSLCTXsetverify(ctx, SSL_VERIFY_PEER, nil);  SSLCTXsetmode(ctx, SSL_MODE_AUTO_RETRY);   // Create SSL connection  ssl := SSLnew(ctx);  if ssl = nil then  begin    Writeln('Error creating SSL connection');    Halt(1);  end;   // Create simple socket  CSocket := fpsocket(AF_INET, SOCK_STREAM, 0);  if CSocket = -1 then  begin    WriteLn('Error creating socket');    Halt(1);  end;   // Resolve domain name to IP adress  hrs := THostResolver.Create(nil);  if hrs.NameLookup(Host) then  begin    IPAddr := hrs.AddressAsString;    WriteLn('Resolved IP Address: ', IPAddr);  end  else  begin    WriteLn('Failed to resolve the hostname: ', Host);    Halt(1);  end;   // Connect to host  with Address do   begin      sin_family := AF_INET; //TCP/IP      sin_port:= htons(word(Port)); //Port      sin_addr:=StrToNetAddr(hrs.AddressAsString); // IP address   end;   hrs.Free;   if fpconnect(CSocket, @Address, SizeOf(Address)) < 0 then  begin    WriteLn('Error connecting to server.');    Halt(1);  end;   writeln('Connected ', Host, ':', Port);   // Set file descriptor (fd) of connected socket to SSL connection  SSLsetfd(ssl, CSocket);    // Establish SSL connection  if SslConnect(ssl) <= 0 then  begin    Writeln('SSL connection error.');    Halt(1);  end;  Writeln('SSL connection established.');  WriteLn('----' + #13#10 + 'SSL connection cipher description:');  // https://www.openssl.org/docs/manmaster/man3/SSL_get_cipher.html  cipherPtr := SSLgetcurrentcipher(ssl);  PrintSSLCipherInfo(cipherPtr^);  WriteLn('----');  // https://www.openssl.org/docs/manmaster/man3/SSL_get_version.html  WriteLn('SSL/TLS version: ' + SslGetVersion(ssl));  WriteLn('----');  // https://www.openssl.org/docs/manmaster/man3/SSL_get_peer_certificat e.html  server_cert := SslGetPeerCertificate(ssl);  WriteLn('Server certificate:');  SetLength(tempBuf, 1024);  // https://www.openssl.org/docs/man3.0/man3/X509_NAME_oneline.html  // ht tps://www.openssl.org/docs/manmaster/man3/X509_get_subject_name.html  cert_str := X509NameOneline(X509GetSubjectName(server_cert), tempBuf, Length(tempBuf));  cert_str := StringReplace(cert_str, '\xC2\xA0', ' ', [rfReplaceAll]);  WriteLn('Subject: ', cert_str);  // https://www.openssl.org/docs/manmaster/man3/X509_get_issuer_name.html  cert_str := X509NameOneline(X509GetIssuerName(server_cert), tempBuf, Length(tempBuf));  cert_str := StringReplace(cert_str, '\xC2\xA0', ' ', [rfReplaceAll]);  WriteLn('Issuer: ', cert_str + #13#10);   // We could do all sorts of certificate verification stuff here before deallocating the certificate  // https://www.openssl.org/docs/manmaster/man3/X509_free.html  X509free(server_cert);   // Create an HTTP GET request.  request :=  'GET / HTTP/1.1'#13#10 +    'Host: ' + Host + #13#10 +    'Connection: close'#13#10 +    'User-Agent: Example TLS client'#13#10#13#10;   // Send the request to the server.  WriteLn('--> Sending to the server:');  Write(request);  // https://www.openssl.org/docs/manmaster/man3/SSL_write.html  nbytes_written := SslWrite(ssl, PChar(request), Length(request));  if nbytes_written <> Length(request) then  begin    WriteLn('Could not send all data to the server');    Halt(1);  end;   WriteLn('--> Sending to the server finished');  WriteLn('<-- Receiving from the server:');   // Receive and display the server's response.  repeat    // https://www.openssl.org/docs/manmaster/man3/SSL_read.html    nbytes_read := SslRead(ssl, @in_buf, BUF_SIZE);    if nbytes_read <= 0 then    begin      ssl_error := SSLgeterror(ssl, nbytes_read);      if ssl_error = SSL_ERROR_ZERO_RETURN then        Break      else      begin        WriteLn('Error ', ssl_error, ' while reading data from the server');        Halt(1);      end;    end;     Write(UTF8Encode(Copy(in_buf, 0, nbytes_read)));  until False;   WriteLn('<-- Receiving from the server finished');    // Send SSL/TLS close_notify  // https://www.openssl.org/docs/manmaster/man3/SSL_shutdown.html  repeat    ssl_error := SslShutdown(ssl);    until ssl_error <> 0;   if ssl_error = 1 then      WriteLn('SSL connection sussefully closed.')  else      // https://www.openssl.org/docs/manmaster/man3/SSL_get_error.html      WriteLn('SSL connection closed with error.', SSLgeterror(ssl, ssl_error));   // Close socket  CloseSocket(CSocket);   // Clean up.  if Assigned(ssl) then    SslFree(ssl);   if Assigned(ctx) then    SSLCtxFree(ctx);end. ---------------------------------------------------------------------- toby · 2023-09-14 16:27 doing Vespa mandarinia works ... delphius for me i tried to use the fpc sockets unit and indy library a long time ago and got nowhere with either - synapse just worked immediately and never had any problems since (that rvk couldn't fix) i can't wait to see if your code fills in this hole - it would be nice to have an fpc sockets program paweld all the .h files are ususally installed when compiling source - so you probably never noticed them not being there - but the distros separate them all into different (bothersome) packages would you be upset if i replaced your nice synapse code with curl code?   (just joking i don't have time to do it anyway) ---------------------------------------------------------------------- toby · 2023-09-14 17:10 delphius these are the kind of compiler errors i got originally when i first tried the fpc sockets unit your line is 42 is my line 47 opensslget.pas(47,7) Error: Wrong number of parameters specified for call to "InitSSLInterface" openssl.pas(5644,10) Error: Found declaration: InitSSLInterface:Boolean; openssl.pas(1495,10) Error: Found declaration: InitSSLInterface(Boolean):Boolean; InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext); - your filepath also points to the current dir (i guess for where the .dll will be) but my libssl.so is in /usr/local/lib64/ which links to /usr/local/lib64/libssl.so.3 i am using a debian based os with fpc-3.2.2 --- ---------------------------------------------------------------------- paweld · 2023-09-14 17:20 @delphius: You can use fphttpclient and that will work (the original version uses that). It's just that fpc 3.2 supports openssl at max version 1.1, so it's not very universal (which is @maurobio's goal) because most Linuxes already have openssl version 3.        Quote from: tobywould you be upset if i replaced your nice synapse code with curl code?I don't mind, I would even like to see another solution to this problem ---------------------------------------------------------------------- rvk · 2023-09-14 17:25 Quote from: paweld on September 14, 2023, 05:00:48 pmQuote from: rvkBut for a clean system, libssl-dev shouldn't be needed. Just the libssl would be sufficient for the executable.I just now checked on a freshly installed system (Debian 12). After the installation I have openssl version 3.0.9, but the program does not download over https. Only installing the libssl-dev package (also version 3.0.9) makes all the data downloaded.    Uninstalling the package makes it fail again over https.    I would be interested to see the apt-get install log for that. What gets installed alongside libssl-dev and also what get deleted again when uninstalling it. Looking at the contents of libssl-dev there isn't really anything in that package itself which would be used at runtime. So it must be something that gets installed alongside. (I also found it strange that on a clean mint with OpenSsl 3, it works without, but I'll check that myself again later on) ---------------------------------------------------------------------- delphius · 2023-09-14 17:53 Quote from: paweld on September 14, 2023, 07:20:09 pm@delphius: You can use fphttpclient and that will work (the original version uses that). I am not referring to the already implemented functionality (tfphttpclient), but something that is not yet available in clean fpc, for example, sending e-mail via smtps, etc. Quote from: paweld on September 14, 2023, 07:20:09 pmIt's just that fpc 3.2 supports openssl at max version 1.1, so it's not very universal (which is @maurobio's goal) because most Linuxes already have openssl version 3. 1. Mormot wraper is production ready, its a pro, but it pulls dependencies from its core, its a con 2. Native fpc opensslpas it is a collection of support for all conceivable and unimaginable versions of the library for all platforms, which on the one hand is good, but on the other requires constant painstaking work to keep it up to date, which, as we see now, has led to a strong lag 3. Guaranteed solution is either static assembly or delivery of the necessary versions of the library files with the application, which is a blessing for windows, but for linux it is a bad thing ---------------------------------------------------------------------- delphius · 2023-09-14 18:00 Quote from: toby on September 14, 2023, 07:10:04 pmthese are the kind of compiler errors i got originally when i first tried the fpc sockets unit This is just an example written on the knee under windows and not adapted to linux, clearly repeating the functionality of ssl/tls connections implemented under the hood of fphttpclient Quote from: toby on September 14, 2023, 07:10:04 pmyour filepath also points to the current dir (i guess for where the .dll will be) but my libssl.so is in /usr/local/lib64/ which links to /usr/local/lib64/libssl.so.3 i am using a debian based os with fpc-3.2.2 Try just to comment out Quote// InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext);and it will be automatically initiated in the next function OpenSSLGetVersion with InitSSLInterface without params ---------------------------------------------------------------------- rvk · 2023-09-14 18:48 Quote from: delphius on September 14, 2023, 07:53:11 pm2. Native fpc opensslpas it is a collection of support for all conceivable and unimaginable versions of the library for all platforms, which on the one hand is good, but on the other requires constant painstaking work to keep it up to date, which, as we see now, has led to a strong lag The code used in openssl.pas comes from Synapse. The only downside is that it's compiled in FPC. And you can't easily change the openssl unit without recompiling FPC (which is hard when using release Synapse). BTW. I showed earlier that you can manipulate DLLVersions array to add your own without the need of recompiling FPC (you just need to replace an older version with '.3'.). If they made it an dynamic array it would heven be easier. But you can also use Synapse itself which is updated for the latest versions on Windows and Linux and you don't need to recompile FPC either for using that. Yes, you can create the whole openssl.pas from Synapse yourself in code (or do something like you showed) but why would you do that if there is Synapse? And what to do with the special functions for using sockets and openssl (which are all in Synapse)? Just using Synapse seems much easier and stable to me. Synapse on Android might be a challenge (although there is a version for it I think) but changing that socket/ssl code to support Android seems like a challenge too PS. Your code is still very interesting for the purist under us who want to use as few units as possible But would also need to be expanded for 64 bit (which has another dll), Linux, Android etc. You'll probably end up with a unit similar to openssl.pas from Synapse. ---------------------------------------------------------------------- delphius · 2023-09-14 19:07 Quote from: rvk on September 14, 2023, 08:48:12 pmJust using Synapse seems much easier and stable to me. It seems to me that this is the main reason, and for different people you just need to substitute the name of the net library they are familiar with  Quote from: rvk on September 14, 2023, 08:48:12 pm Your code is still very interesting for the purist under us who want to use as few units as possible Thank you, I'm doing all this in the context of the solving task of writing a collection of simple functions for sending emails from fpc, now it's OpenSSL's turn, there is already implemented ssl/tls functionality using Cryptlib (I still can't understand why it is not popular) Quote from: rvk on September 14, 2023, 08:48:12 pmBut would also need to be expanded for 64 bit (which has another dll), Linux, Android etc. You'll probably end up with a unit similar to openssl.pas from Synapse. It's too ambitious, I'm trying to solve feasible tasks that will benefit here and now. But if we approach this issue conceptually, then I would simply transpile the last openssl lib c header file(s) for the current library development branch (3.x) and rely on it, discarding all the old versions, taking into account the end of support for old branches ---------------------------------------------------------------------- rvk · 2023-09-14 19:18 Quote from: delphius on September 14, 2023, 09:07:57 pmThank you, I'm doing all this in the context of the solved task of writing a collection of simple functions for sending emails from fpc, now it's OpenSSL's turn, there is already implemented ssl/tls functionality using Cryptlib (I still can't understand why it is not popular)The last time I checked, Cryptlib isn't free to use in commercial closed- source programs. QuoteIn addition, cryptlib is often free for use in low-cost, non- open-source applications such as shareware, and for personal and research use. ---------------------------------------------------------------------- toby · 2023-09-14 19:27 i had commented it to see if it would compile but had a haltl after it this is what i get when i remove the halt OpenSSL version: Could not create SSL context i don't know if you plan or want to spend time having it work on linux - but i am here for you (bribe rvk to look at it ---------------------------------------------------------------------- maurobio · 2023-09-14 20:24 Hi, Gentlemen! I have yet more news to report. First, I did a small change to the code provided by @paweld. I did not made any changes to the code itself, just moved four routines (GetUrlToFile, GetImgUrlToBase64Png, GetAndMergeImages, IsOnline) from the BioWS unit to the main program unit. This is because these routines are used only by the e-Species Desktop application, and the online searching routines in BioWS are intended to be used in other programs too (as part of my BioLib project, about which I can tell more in another moment). In the process of moving these four routines between units, I found what looks like a curious bug in GetImgUrlToBase64Png. Here is the declaration of this function: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetImgUrlToBase64Png(Url: string; InlineImg: boolean;  newWidth: integer; newHeight: integer; Proportional: boolean): string; Before moving it from the BioWS unit to the main unit, it was called by the main program as follows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i GetImgUrlToBase64Png(imgUrl, True, 94, 145) Notice the missing last boolean parameter. But no error was issued! However, when I moved the function declaration to the main program unit, compilation failed because of that missing parameter; I then just change the call to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i GetImgUrlToBase64Png(imgUrl, True, 94, 145, True) and now of course compilation was successful. Second, I found what may be an "intermittent" bug which appears only at times: when I search for the name "Panthera leo" (the African lion) sometimes no bibliographic reference is returned; other times a list of references related to that species is displayed as expected. I didn't found this problem with any other species name which I tested. Is there any conceivable way around this? Implemented this minor modification as suggested by @rvk Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         Result1 := EvaluateXPathExpression('//Article/ArticleTitle', Doc.DocumentElement);        Result2 := EvaluateXPathExpression('//Pub medData/ArticleIdList/ArticleId[@IdType="doi"]', Doc.DocumentElement);        NodeSet1 := Result1.AsNodeSet;        NodeSet2 := Result2.AsNodeSet;        if NodeSet1.Count > 0 then      begin          for i := 0 to NodeSet1.Count - 1 do          try          if i <= NodeSet2.Count - 1 then              references.Add(TDomElement(NodeSet1.Items[i]).TextContent + '=' + TDomElement(NodeSet2.Items[i]).TextContent);          except          continue;          end;        end; caused other names (eg., "Vicia faba") to return no reference (as in the above mentioned "Panthera leo" search). Quoteold version of synapse (40, stable) does not support openssl 3 Sure, I am using the trunk version, just commented about being able to compile and run the program with the original stable version of Synapse under Windows (it does not even compile under Linux). I have not yet time to test the Linux version (probably will get it done only by tomorrow). With warmest regards, ---------------------------------------------------------------------- maurobio · 2023-09-14 20:38 Hi, @rvk! Ave, @delphius! QuoteJust using Synapse seems much easier and stable to me. I like the biologically-inspired name too...  But now I have to tike the time to learn how to use it, whereas I was already (more or less) familiar with fhttpclient. QuoteSynapse on Android might be a challenge (although there is a version for it I think) but changing that socket/ssl code to support Android seems like a challenge too And now for an interesting coincidence... @rvk mentioned Android precisely when I intended to post a message asking about that! That's because I am crazy (or stupid, or both) enough to have start developing an Android version (using LAWM) of eSpecies which partially works! I am using the jHttpClient which comes with LAMW but my code (based on the (now outdated) online searching routines used by eSpecies Desktop is plagued probably by the very same problems already pointed out by @rvk. If you wizards would like to take a look at my humble and messy code, I can of course share the code anytime! Just imagine being able to look up information on any biological species anywhere in the world using a mobile device!  With warmest regards, ---------------------------------------------------------------------- paweld · 2023-09-14 21:12 Quote from: maurobioIn the process of moving these four routines between units, I found what looks like a curious bug in GetImgUrlToBase64PngParameters of functions / procedures can have defined default values. The function you specified had them set like this:Code: [Select]function GetImgUrlToBase64Png(Url: String; InlineImg: Boolean; newWidth: Integer = 0; newHeight: Integer = 0; Proportional: Boolean = False): String; Quotewhen I search for the name "Panthera leo" (the African lion) sometimes no bibliographic reference is returned; other times a list of references related to that species is displayed as expected.I tested several times and did not experience this problemQuoteCode: [Select]if NodeSet1.Count > 0 then begin   for i := 0 to NodeSet1.Count - 1 do//...This `if` is not needed here, because if the list is empty (count = 0) then the loop will not execute (`for i := 0 to -1 do`) ---------------------------------------------------------------------- delphius · 2023-09-14 21:49 Quote from: toby on September 14, 2023, 09:27:33 pmi don't know if you plan or want to spend time having it work on linux - but i am here for you 1. Installed debian based linux in a virtual machine 2. Installed the latest version of fpc&laz (trunk) using fpcupdeluxe 3. Installed and configured VSCode (omnipascal + tasks.json) 4. Compiled and works without errors (screenshots attached). Try it too on the latest version of fpc ---------------------------------------------------------------------- toby · 2023-09-14 22:30 paweld a simple curl code that does away with direct openssl code etc always save my curl to file in case they change stuff and don't have to reget their pages if don't want it and want it in a tstringlist directly use tprocess.execute etc uncomment line 25 to enable downloading Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program ecurl; uses sysutils, classes; // classes for astringlist label 10; const list : array[1..5] of ansistring = ('asian giant hornet', 'lima bean', 'apple', 'human', 'fava bean'); var en, s, d, d1, l : ansistring;    n, i : longint;    sp  : tstringlist;    html : text; begin writeln; sp := tstringlist.create; for i := 1 to high(list) do  begin  en := stringreplace(list[i], ' ', '_', [rfReplaceAll]);  l := '-A Mozilla/4.0 -L -k -o ' + en + '.html ' + 'https://en.wikipedia.org/wiki/' + en;  writeln('retrieving ', l);//  sysutils.executeprocess('/ram/curl', l); // line 25   uncomment to do download   assign(html, en + '.html');  reset(html);  d := '';10:  readln(html, d1);  d := d + d1;  if not eof(html) then goto 10;  close(html); //Species:
V. mandarinia
', d);  delete(d, 1, (n + 2));  n := pos('', d);  s := copy(d, 1, (n - 1));  s := stringreplace(s, ' ', ' ', [rfReplaceAll]);  writeln('Species : ', s);  sp.add(s);//  writeln(sp.count);  writeln;  end;writeln; for i := 1 to sp.count do writeln(list[i], ' : ', sp[i - 1]); sp.free; writeln; end.  now to concentrate on the code from delphius ---------------------------------------------------------------------- rvk · 2023-09-14 22:48 Quote from: paweld on September 14, 2023, 11:12:01 pmParameters of functions / procedures can have defined default values. The function you specified had them set like this:Code: [Select]function GetImgUrlToBase64Png(Url: String; InlineImg: Boolean; newWidth: Integer = 0; newHeight: Integer = 0; Proportional: Boolean = False): String; Yes, in the interface it was declared as: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   function GetImgUrlToBase64Png(Url: String; InlineImg: Boolean; newWidth: Integer = 0; newHeight: Integer = 0; Proportional: Boolean = False): String;But in the implementation it is like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetImgUrlToBase64Png(Url: String; InlineImg: Boolean; newWidth: Integer; newHeight: Integer; Proportional: Boolean): String;Although it's not a problem with compiling, my preference is to always match those two, so it's also clear in the implementation that the Proportional parameter is optional. Quote from: maurobio on September 14, 2023, 10:24:33 pmSecond, I found what may be an "intermittent" bug which appears only at times: when I search for the name "Panthera leo" (the African lion) sometimes no bibliographic reference is returned; other times a list of references related to that species is displayed as expected. I didn't found this problem with any other species name which I tested. Is there any conceivable way around this?Those intermittent problems come because you have the exception handling on many places without ANY feedback. You just return result = empty. But it's sometimes better to give feedback to what exactly is going on with those exceptions. When running in the IDE you WILL receive those exceptions dialogs (even if you handle the exception afterwards). Then you can see where things go wrong. That's why I said it's best to examine exceptions and always give feedback. If you get feedback for which you can explain the cause, like that ResultSet1 being a different size than ResultSet2, you should program around that, so that you don't get an exception for that anymore. You end up only with REAL exceptions which are unexpected, and it is good to give feedback to the user then. Now the exceptions are all handled silently and you don't know when and if they occur, end you just end up with an 'empty' result. Quote from: maurobio on September 14, 2023, 10:24:33 pmImplemented this minor modification as suggested by @rvk Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         Result1 := EvaluateXPathExpression('//Article/ArticleTitle', Doc.DocumentElement);        Result2 := EvaluateXPathExpression('//Pub medData/ArticleIdList/ArticleId[@IdType="doi"]', Doc.DocumentElement);        NodeSet1 := Result1.AsNodeSet;        NodeSet2 := Result2.AsNodeSet;        if NodeSet1.Count > 0 then      begin          for i := 0 to NodeSet1.Count - 1 do          try          if i <= NodeSet2.Count - 1 then              references.Add(TDomElement(NodeSet1.Items[i]).TextContent + '=' + TDomElement(NodeSet2.Items[i]).TextContent);          except          continue;          end;        end; caused other names (eg., "Vicia faba") to return no reference (as in the above mentioned "Panthera leo" search). That's strange. That would also happen if you didn't add that if line. Because when i > NodeSet2.Count - 1 you would get an exception and you would continue. So with that line the exception doesn't happen and should return the same as when the exception did happen. I think there is some other exception going on there (for example with retrieving the data), but because you handle that silently, you don't see that. My advice... build showmessage's in ALL except parts and just let them happen (visibly). Then, go through them and solve them all via code (like I did here with the if line). Don't handle exceptions silently (unless you know why the exception is happening and it is intended, which is certainly not true for an empty result) ---------------------------------------------------------------------- toby · 2023-09-14 23:16 i am not just trying to get OpenSSLGetVersion to work right after your begin i have or i := 1 to 10 do // test all integers   7 fails?  WriteLn('OpenSSL version: ' + OpenSSLGetVersion(i)); // OPENSSL_FULL_VERSION_STRING     halt; i have the latest openssl.pas    from git clone https://gitlab.com/freepascal.org/fpc/source.git fpc  202841 Sep 14 2023 17:01:38 openssl.pas the following openssl.rsjwas generated in the dir i am working in - to be honest i don't think i've ever seen a .rsj file before openssl.rsj {"version":1,"strings":[ {"hash":251958569,"name":"openssl.sfailedtoloadopenssl","sourcebytes": [70,97,105,108,101,100,32,116,111,32,108,111,97,100,32,79,112,101,110, 83,83,76,32,108,105,98,114,97,114,121],"value":"Failed to load OpenSSL library"} ] when i compile with my new -uvt toy i see openssl.pas(1704,32) Hint: C arrays are passed by reference ---------------------------------------------------------------------- rvk · 2023-09-14 23:24 Quote from: toby on September 15, 2023, 01:16:29 ami am not just trying to get OpenSSLGetVersion to work right after your begin i have or i := 1 to 10 do // test all integers   7 fails?  WriteLn('OpenSSL version: ' + OpenSSLGetVersion(i)); // OPENSSL_FULL_VERSION_STRING And what openssl version do you have on your computer? Code: [Select]openssl version (I thought OpenSSLGetVersion was only available for 3+, or maybe 1.1+.) ---------------------------------------------------------------------- toby · 2023-09-14 23:35 openssl version OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022) ---------------------------------------------------------------------- delphius · 2023-09-15 04:51 Quote from: toby on September 15, 2023, 01:16:29 amor i := 1 to 10 do // test all integers   7 fails? And why not from 0 to 9?  These constants are for version 3+, in 1.1.1 there were 6 of them Quoteconst char *OpenSSL_version(int type); # define OPENSSL_VERSION                0 # define OPENSSL_CFLAGS                 1 # define OPENSSL_BUILT_ON               2 # define OPENSSL_PLATFORM               3 # define OPENSSL_DIR                    4 # define OPENSSL_ENGINES_DIR            5 # define OPENSSL_VERSION_STRING         6 # define OPENSSL_FULL_VERSION_STRING    7 # define OPENSSL_MODULES_DIR            8 # define OPENSSL_CPU_INFO               9 QuoteOpenSSL_version() returns different strings depending on t: OPENSSL_VERSION The value of OPENSSL_VERSION_TEXT OPENSSL_VERSION_STRING The value of OPENSSL_VERSION_STR OPENSSL_FULL_VERSION_STRING The value of OPENSSL_FULL_VERSION_STR OPENSSL_CFLAGS The compiler flags set for the compilation process in the form compiler: ... if available, or compiler: information not available otherwise. OPENSSL_BUILT_ON The date of the build process in the form built on: ... if available or built on: date not available otherwise. The date would not be available in a reproducible build, for example. OPENSSL_PLATFORM The "Configure" target of the library build in the form platform: ... if available, or platform: information not available otherwise. OPENSSL_DIR The OPENSSLDIR setting of the library build in the form OPENSSLDIR: "..." if available, or OPENSSLDIR: N/A otherwise. OPENSSL_ENGINES_DIR The ENGINESDIR setting of the library build in the form ENGINESDIR: "..." if available, or ENGINESDIR: N/A otherwise. This option is deprecated in OpenSSL 3.0. OPENSSL_MODULES_DIR The MODULESDIR setting of the library build in the form MODULESDIR: "..." if available, or MODULESDIR: N/A otherwise. OPENSSL_CPU_INFO The current OpenSSL cpu settings. This is the current setting of the cpu capability flags. It is usually automatically configured but may be set via an environment variable. The value has the same syntax as the environment variable. For x86 the string looks like CPUINFO: OPENSSL_ia32cap=0x123:0x456 or CPUINFO: N/A if not available. For an unknown t, the text not available is returned. ---------------------------------------------------------------------- rvk · 2023-09-15 11:03 Quote from: paweld on September 14, 2023, 05:00:48 pmQuote from: rvkBut for a clean system, libssl-dev shouldn't be needed. Just the libssl would be sufficient for the executable.I just now checked on a freshly installed system (Debian 12). After the installation I have openssl version 3.0.9, but the program does not download over https. Only installing the libssl-dev package (also version 3.0.9) makes all the data downloaded.    Uninstalling the package makes it fail again over https.    I had some time to investigate this. Why was libssl-dev package needed? It seems that FPC/openssl doesn't have a problem and for openssl in FPC the libssl-dev doesn't need to be installed. The reason for this is that the openssl in FPC searches for ALL possible library names of openssl (so 1.0.2, 1.1 and 3). BUT... the openssl from Synapse only checks the basic library name: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DLLSSLName: string = 'libssl.so';DLLUtilName: string = 'libcrypto.so'; So when you use the openssl from Synpase you need to have a symlink pointing to the actual openssl library. And the libssl-dev happens to makes that symlink: Code: [Select]libssl-dev: /usr/lib/aarch64-linux-gnu/libcrypto.so libssl-dev: /usr/lib/aarch64-linux-gnu/libssl.so You could make those symlink yourself in your program but that's the only thing that's needed, not the entire libssl-dev itself. (But installing libssl-dev might be a bit easier ) ---------------------------------------------------------------------- rvk · 2023-09-15 12:23 O, and @paweld and @maurobio. I found a few other issues. In Snippet() and Images() there is a construct to do a Get() on the redirect URL. If it succeeds then there is a assignment to queryStr (from the redirect or direct from searchStr). But if it fails, then queryStr is empty. Normally the Get() won't fail but you can't be certain of that. So queryStr should be initialized to searchStr anyway at the start of those procedures. And to @paweld... I saw you catch every except in the LPDNetU. For a 'low-level' library, maybe it should not catch those exceptions but pass them on to the caller. Now it wasn't even possible to catch the exception that OpenSSL wasn't found because the exception was ignored silently. ---------------------------------------------------------------------- maurobio · 2023-09-15 13:18 Hi, Gentlemen! I have some weird news... Just completed my tests on Windows 10, Linux Mint 19.1 (32-bits) and Lubuntu Linux 18.04 (64-bits), with Lazarus 2.0.12 and OpenSSL 1.1.1 installed in Linux and OpenSSL 1.0.2 installed in Windows. For comparison, I tested @paweld modified code using Synapse and my original version of eSpecies, with a fix for the problem with Wikipedia, substituting the previous code with the one below: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TWikiSearch.Snippet(const searchStr: string): string;var  JsonData: TJsonData;  Client: TFPHttpClient;begin  Client := TFPHttpClient.Create(nil);  try    try      { Allow redirections }    Client.AllowRedirect := True;      JsonData := GetJson(Client.Get(WIKIPEDIA_URL +        StringReplace(searchStr, ' ', '_', [rfReplaceAll])));      Result := JsonData.FindPath('extract').AsUnicodeString;    except      Result := '';    end;  finally    JsonData.Free;    Client.Free;  end;end; With @paweld code, the program worked fine under Windows but did not work under either Linux distro: no errors were issued, but no search results were returned (see the screenshot below)! However, on all platforms, my original code worked fine (with just the above modification). I also tested the program in two machines without Lazarus installed, one with Windows 7 (32-bits) with OpenSSL 1.0.2 -- where both my original version and @paweld's worked -- and another one with Linux Mint 21 (64-bits) with OpenSSL 3.0.2 -- where neither my original version nor @paweld version worked. To sum up: it seems that in the end the really serious issue is the version of OpenSSL installed on a given machine; it seems that the program does not work with version 3.x. Maybe, it does not matter if one is using Synapse or the FPC networking routines, because if neither support OpenSSL 3.x, the program will not work anyway. I obviously cannot oblige users to downgrade their Linux systems by removing OpenSSL 3.x and replacing it with OpenSSL 1.x (because that would break their systems), but would it be possible to have both versions (1.x and 3.x) installed on the same machine? And if so, how to instruct the program to use the older version instead of the newer one? With warmest regards, With warmest regards, ---------------------------------------------------------------------- delphius · 2023-09-15 13:19 In order not to clog up the topic of the respected maurobio with unnecessary information, I took the discussion of the direct use of OpenSSL in a separate topic ---------------------------------------------------------------------- maurobio · 2023-09-15 13:24 Ave, @delphius! QuoteIn order not to clog up the topic of the respected maurobio with unnecessary information, I took the discussion of the direct use of OpenSSL in a separate topic I just noticed it. I will follow that discussion, because your proposal could perhaps make things simpler. But in this matter I am just an amateur and can only follow the discussions in the hope that some useful code arises from them!  With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-15 13:29 Quote from: maurobio on September 15, 2023, 03:18:00 pmI also tested the program in two machines without Lazarus installed, one with Windows 7 (32-bits) with OpenSSL 1.0.2 -- where both my original version and @paweld's worked -- and another one with Linux Mint 21 (64-bits) with OpenSSL 3.0.2 -- where neither my original version nor @paweld version worked.Read my last post. For the openssl in Synapse to work you need a symlink to the openssl libraries. The package libssl-dev will provide that. Do a apt-get and it should work. sudo apt-get install libssl-dev You can create the symlinks yourself but installing that package is the easiest solution. Unfortunatly the exception for OpenSSL not being present doesn't surface because now a lot of exceptions are handled silently (they are just ignored). Not the best practice in my opinion. ---------------------------------------------------------------------- delphius · 2023-09-15 13:31 Quote from: maurobio on September 15, 2023, 03:24:46 pmbecause your proposal could perhaps make things simpler. It is for this reason that I got into the discussion, because in my opinion, in your case no complications are required and there should be enough features provided by the standard fpc libraries. And suggestions, like the working, but odious use of curl directly, only throw you off course. ---------------------------------------------------------------------- rvk · 2023-09-15 13:35 Quote from: delphius on September 15, 2023, 03:31:38 pmIt is for this reason that I got into the discussion, because in my opinion, in your case no complications are required and there should be enough features provided by the standard fpc libraries. The problem with the standard library is that it doesn't yet support OpenSSL 3. You could program code like your showed but that only works for Windows (and here both Linux and Windows is needed, and even Android in the future). So if you can provide the same code cross-platform it can be used. (But you'll end up with roughly the code as openssl.pas ) The downside of openssl.pas is that the DLLVersions is not dynamic but you can replace the oldest version with .3 and it will work for the newer OpenSSL 3 too (as I showed). (but at that point we already moved on to Synapse which works fine too, I use that a lot too, also in Delphi.) ---------------------------------------------------------------------- maurobio · 2023-09-15 13:45 Hi, @rvk! QuoteThe package libssl-dev will provide that. Well, I can understand this, but I did not did it because of another post where in a reply to @paweld you asked if libssl-dev should be really necessary... I just got confused!  QuoteUnfortunately the exception for OpenSSL not being present doesn't surface because now a lot of exceptions are handled silently (they are just ignored). Not the best practice in my opinion. I do understand and agree. I intend to improve the code for handling the exceptions in a more careful way, but I first need to have working versions of the program, so that I can proceed from them! So, I first needed to understand that some of the problems with my program were simply these issues with OpenSSL (and it took me days to do so...). With warmest regards, ---------------------------------------------------------------------- maurobio · 2023-09-15 13:49 Ave, @delphius! QuoteAnd suggestions, like the working, but odious use of curl directly, only throw you off course. I do admit that in fact, sometimes I get lost along these discussions, because I don't know if the problem is with my code, the networking libraries used in the code, the system's required libraries, or a combination of all these ...  With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-15 14:42 Quote from: maurobio on September 15, 2023, 03:45:37 pmQuoteThe package libssl-dev will provide that.Well, I can understand this, but I did not did it because of another post where in a reply to @paweld you asked if libssl-dev should be really necessary... I just got confused!  Yes, that was a reply from me. I was puzzled as to why libssl-dev was needed. But I checked it out and it seems Synpase/openssl needs the symlink libssl-dev provides (besides the header files). I was puzzled because the openssl.pas version from FPC doesn't need that symlink ---------------------------------------------------------------------- paweld · 2023-09-15 14:55 Quote from: rvkI had some time to investigate this. Why was libssl-dev package needed? It seems that FPC/openssl doesn't have a problem and for openssl in FPC the libssl-dev doesn't need to be installed. The reason for this is that the openssl in FPC searches for ALL possible library names of openssl (so 1.0.2, 1.1 and 3). BUT... the openssl from Synapse only checks the basic library name: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DLLSSLName: string = 'libssl.so';DLLUtilName: string = 'libcrypto.so'; So when you use the openssl from Synpase you need to have a symlink pointing to the actual openssl library. And the libssl-dev happens to makes that symlink: Code: [Select]libssl-dev: /usr/lib/aarch64-linux-gnu/libcrypto.so libssl-dev: /usr/lib/aarch64-linux-gnu/libssl.so You could make those symlink yourself in your program but that's the only thing that's needed, not the entire libssl-dev itself. (But installing libssl-dev might be a bit easier ) @rvk thank you very much for this valuable information.      Quote from: rvkAnd to @paweld... I saw you catch every except in the LPDNetU. For a 'low-level' library, maybe it should not catch those exceptions but pass them on to the caller. Now it wasn't even possible to catch the exception that OpenSSL wasn't found because the exception was ignored silently.But these are all functions, so they return False in case of any failure. But you are right, it would be useful to know about the inability to load openssl for encrypted connections.    Quote from: maurobioWith @paweld code, the program worked fine under Windows but did not work under either Linux distro: no errors were issued, but no search results were returned (see the screenshot below)!as @rvk said - you must install libssl-dev package.      When I find some time I will try to make some changes to the code, implementing the ideas suggested by @rvk. ---------------------------------------------------------------------- toby · 2023-09-15 23:25 delphius how are you using InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext); when the function in openssl.pas is function InitSSLInterface(AVerboseLoading: Boolean): Boolean ; overload; deprecated; your rude comment about my curl code is not appreciated in the least - i'm pretty sure more people use curl then use fpc sockets and don't think using it is odious --- rvk is my problem the the openssl.pas doesn;t support openssl-3 - i didn't see amy UNIX or LINUX defs in it?? is it just fopr ps2 os2 and windows? after upgrading to fpc-3.1.1 the openssl.rsj file never came back looks like it supports libressl - i've tried libressl on another system and i think it was slower?? so i went back to openssl --- ---------------------------------------------------------------------- delphius · 2023-09-16 05:20 Quote from: toby on September 16, 2023, 01:25:14 amyour rude comment about my curl code is not appreciated in the least - i'm pretty sure more people use curl then use fpc sockets and don't think using it is odious I deeply apologize if I offended you by this comment, since I use machine translation and I am not a native speaker, I do not fully understand how correct the output phrases are  In fact, I just wanted to warn the author of the topic against rash steps, because at one time I tried to help him with setting up the first version of his program (cgi) on a free hosting, which of course was not successful due to significant restrictions to such programs on such hostings. He relies entirely on our competent opinion, but the task was extremely simple and did not require anything other than the capabilities available in fpc and it remained so in my opinion. As long as I follow the discussion, problems in the code itself are now surfacing, not related to language capabilities or technologies (cgi, desktop/web app, curl or something else), but related to the processing of all possible situations and options, errors, etc. And I still think that the author of the topic could safely use the very first option (cgi), although for minimal money, for example in a docker container on cloud hosting, but he needs an absolutely free open hosting method, so he went further And I also understand that everything that is not being done is for the best, since the business logic of his application does not change as a result of these studies, but only improves (now with the help of the community), and the author himself gains knowledge and skills of new technologies by implementing various wrappers for his business logic However, whatever way we would ultimately choose to provide this amazing free open source service to the world, the essence remains the essence, we just need to give it round-the-clock uninterrupted access and it does not matter for the end user how it will work under the hood. Quote from: toby on September 16, 2023, 01:25:14 amhow are you using InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext); when the function in openssl.pas is function InitSSLInterface(AVerboseLoading: Boolean): Boolean ; overload; deprecated; I use a newer version of FPC than you, so my openssl.pas is different from yours, you can make sure that the function I use is present in the latest version, and the function version you are using is there too for compatibility with old versions But the method I use (forced using dll/so from the program folder) is not approved under linux (although I can't understand who can forbid me to distribute an application for any operating system this way or even by statically compiling the necessary libraries inside the program, since the final task for me is just to make it work right away and not require no additional actions from the user) P.S. Colleagues are already doing a separate header file for openssl3 for the amiga while we are discussing our problems here ---------------------------------------------------------------------- maurobio · 2023-09-16 11:56 Hi, @toby! Quoteyour rude comment about my curl code is not appreciated in the least - i'm pretty sure more people use curl then use fpc sockets and don't think using it is odious Gentlemen, please! Seeing you, wise wizards, quarrelling because of my humble program causes me as much anxiety and consternation as that which afflicted Alberto Santos Dumont when he saw his great invention, the airplane, being used as a killing machine in the First World War...  :'( I am sure that @delphius had no intention to offend anyone and, as he himself explained, his use of a less than polite term to refer to Curl (which we all do agree is a really great tool!) was just a misunderstanding. Peace & Love. With warmest regards, ---------------------------------------------------------------------- maurobio · 2023-09-16 12:07 @Ave, delphius! QuoteHe relies entirely on our competent opinion, but the task was extremely simple and did not require anything other than the capabilities available in fpc and it remained so in my opinion. Absolutely true! QuoteAs long as I follow the discussion, problems in the code itself are now surfacing, not related to language capabilities or technologies (cgi, desktop/web app, curl or something else), but related to the processing of all possible situations and options, errors, etc. Quite right! QuoteAnd I also understand that everything that is not being done is for the best, since the business logic of his application does not change as a result of these studies, but only improves (now with the help of the community), and the author himself gains knowledge and skills of new technologies by implementing various wrappers for his business logic Fully agree!!! QuoteHowever, whatever way we would ultimately choose to provide this amazing free open source service to the world, the essence remains the essence, we just need to give it round-the-clock uninterrupted access and it does not matter for the end user how it will work under the hood. Indeed! QuoteBut the method I use (forced using dll/so from the program folder) is not approved under linux (although I can't understand who can forbid me to distribute an application for any operating system this way or even by statically compiling the necessary libraries inside the program, since the final task for me is just to make it work right away and not require no additional actions from the user) And that is the method I would unashamedly embrace and use if any of you provide me with the instructions for doing so!!  In my humble (and no doubt even amateurish) opinion, this would make everything simpler, both for the end users and the developers. Why not just include the required libraries (.so files) in the distribution package for Linux and forcing the program to use these files, no matter what version of OpenSSL is installed in a user's  system? This would provide for much the same simple solution as in Windows? BTW, why some deem a "bad idea" to install DLL's in the Windows system folder (and many programs, including Lazarus itself, do just that) but consider the "right thing" to install .so files in Linux file system? With warmest regards, ---------------------------------------------------------------------- rvk · 2023-09-16 13:30 Quote from: maurobio on September 16, 2023, 02:07:37 pmWhy not just include the required libraries (.so files) in the distribution package for Linux and forcing the program to use these files, no matter what version of OpenSSL is installed in a user's  system? This would provide for much the same simple solution as in Windows?Have you ever tried to take one little pas file source from a very big library? One of the procedures from the Jedi JVCL and JCL libraries for example. Then you come to the conclusion you need to include another unit. But that unit makes use of another unit. And another. And another. You end up with including the complete library anyway. The same goes (mostly) for .so files in Linux. They depend on eachother. The libssl.so depends on a certain version of libc6 which depends on a certain version of yet another lib, etc. etc. Ever tried to install PHP 5 on a newer machine? It asks for the dependency of an older version of a certain library. But you can't install that library because you have a newer version of it and downgrading isn't possible because other components of the system depend on the newer one. No, it's not that easy. But you are welcome to try. You could copy those .so files and set them in the correct LD_LIBRARY_PATH (or add you directory to it). Quote from: maurobio on September 16, 2023, 02:07:37 pmBTW, why some deem a "bad idea" to install DLL's in the Windows system folder (and many programs, including Lazarus itself, do just that) but consider the "right thing" to install .so files in Linux file system?The copying to the system directory was once the idea in Windows but became a problem when every program copied there own version (old or new) to it. What if your program depends on the newer version but another program copies an older version to the system directory. No... copying to the system directory is discouraged for a long time now. You can let the official releases handle the system directory. That's also the case on Linux. Install via apt-get and let the newest known version install. ---------------------------------------------------------------------- maurobio · 2023-09-16 13:42 Hi, @rvk! I can understand what you point out, but on the other side what I want is to have a reliable way of distributing the binary executable of the Linux version of my application (as a Debian package) without having the user to type any further commands in a terminal window! Someone suggested that I add the line: openssl (>=1.0.2k) on the dependencies list of the package, but shouldn't it be libssl1.1 (or 1.0.2, or 3.0.2, whatever)? And what about  libssl-dev? Should it be included also in the dependencies list? If so, what version number? With warmest regards, ---------------------------------------------------------------------- Thaddy · 2023-09-16 13:46 Quote from: rvk on September 16, 2023, 03:30:34 pmNo... copying to the system directory is discouraged for a long time now. That is your most unprofessional answer ever... I will send it to Guinness. ---------------------------------------------------------------------- rvk · 2023-09-16 13:56 Quote from: Thaddy on September 16, 2023, 03:46:46 pmQuote from: rvk on September 16, 2023, 03:30:34 pmNo... copying to the system directory is discouraged for a long time now. That is your most unprofessional answer ever... I will send it to Guinness. Really? Do you encourage it then? ---------------------------------------------------------------------- maurobio · 2023-09-16 14:02 Gentlmen, QuoteThat is your most unprofessional answer ever... I will send it to Guinness. With all due respect, isn't this beyond the point of the discussion?  Even if it ware just an opinion (and I'm not saying it is, I take it as a very professional advice), isn't he entitled to his opinion? Maybe I will regret these words, but I fail to see where can we go amid such harshness.  :'( Peace! With best wishes, ---------------------------------------------------------------------- toby · 2023-09-16 15:33 delphius you are correct i have upgraded to 3.3.1 writeln(InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext)); writeln(InitSSLInterface()); both return true  in 3.3.1 but gives the error on 3.2.2 you can practice your english on us - we'll understand - more important the language we share in common is fpc (sorry i entered say something schmaltzy into my AI translator and this is what came out) --- i tried this on computer with openssl-1.0.2 but with fpc-3.2.2    (same output with fpc-3.3.1 with openssl-3.0.5) for i := 0 to 9 do  WriteLn(i, ' :  OpenSSL version: ' + OpenSSLGetVersion(i)); // OPENSSL_FULL_VERSION_STRING 0 :  OpenSSL version: 1 :  OpenSSL version: 2 :  OpenSSL version: 3 :  OpenSSL version: 4 :  OpenSSL version: 5 :  OpenSSL version: 6 :  OpenSSL version: 7 :  OpenSSL version: 8 :  OpenSSL version: 9 :  OpenSSL version: --- rvk i also have the openssl-1.0.2 libs installed on a computer with fpc-3.3.1 (but with openssl vesion 3.0.5 installed - no problem with any synapse code or curl or httpd or dillo ssl etc) but i do have these libs installed along with the 3.0.5 -rw-r--r-- 1 root root 768714 May 17 2018 07:05:51 /lib/libssl.a lrwxrwxrwx 1 root root     15 Sep 07 2022 09:41:03 /lib/libssl.so -> libssl.so.1.0.0 -r-xr-xr-x 1 root root 517144 May 17 2018 07:05:51 /lib/libssl.so.1.0.0 -rw-r--r-- 1 root root 4556376 May 17 2018 07:05:51 /lib/libcrypto.a lrwxrwxrwx 1 root root      18 Sep 07 2022 09:41:03 /lib/libcrypto.so -> libcrypto.so.1.0.0 -r-xr-xr-x 1 root root 2713248 May 17 2018 07:05:51 /lib/libcrypto.so.1.0.0 - am i correct that synapse doesn't even use openssl.pas unit itself but only uses ssl_openssl.ppu and sssl_openssl_lib.ppu so why isn't fpc using them instead of openssl.pas? --- rvk you actually read what thaddy posts? that is funny - he never responds to his many bogus posts when challenged --- maurobio you don't need to mess with copying dlls to windows system directory - having them in the  current directory you are working in is the best way --- ---------------------------------------------------------------------- delphius · 2023-09-16 18:36 Quote from: toby on September 16, 2023, 05:33:40 pmdelphius you are correct i have upgraded to 3.3.1 writeln(InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext)); writeln(InitSSLInterface()); both return true  in 3.3.1 but gives the error on 3.2.2 OK, but we have to remember what rvk explained above, that we can't just bring our own .so into a linux system by simply using them from a program folder, as they are themselves! depend on the specific! versions of other libraries, which usually does not happen in windows (except for dependencies on various runtimes). Therefore, a valid way in windows would be to force the dll use from the program folder, and in the case of linux, you need to entrust openssl.pas with the help of calling the initialization of the OpenSSL library without parameters, independently find and load the version of the .so libraries installed in the system into the address space of our program (or, accordingly, solve the dependencies automatically by the package installer when installing the application distribution) There is always a second option to build all dependencies statically in the binary file And the third option is to build .so files from sources on the system, then all dependencies will be taken into account and the collected dynamic libraries will work from the program folder as well. Quote from: toby on September 16, 2023, 05:33:40 pmmore important the language we share in common is fpc Absolutely true!)))) ---------------------------------------------------------------------- maurobio · 2023-09-16 18:58 Hi, @toby! Quoteyou don't need to mess with copying dlls to windows system directory - having them in the  current directory you are working in is the best way. Sure! I also prefer this way. Under Windows, my application now runs fine with the required DLLs present in the binary executable folder. What I would like it to be able to do the same thing with the respective Linux shared libraries (.so).... Best regards, ---------------------------------------------------------------------- TRon · 2023-09-16 19:12 Quote from: maurobio on September 16, 2023, 08:58:57 pmWhat I would like it to be able to do the same thing with the respective Linux shared libraries (.so).... Already wrote about that. It will not be accepted in the Linux world. fwiw it works in exactly the same way under Linux as it does on Windows. ---------------------------------------------------------------------- maurobio · 2023-09-16 19:57 Hi, @TRon! Quote fwiw it works in exactly the same way under Linux as it does on Windows. Now it works, after I have installed (on a machine without the Lazarus IDE) the libssl-dev as you wizards have suggested. With best regards, ---------------------------------------------------------------------- maurobio · 2023-09-16 20:07 Hi, Gentlmen! Finally, I have some good news! I gad already managed to get the eSpecies application running under Windows (on a machine without the Lazarus IDE installed), but just including the required OpenSSL DLL files in the same folder of the application. Now, I got the Linux versions (32- and 64-bits) also working (again, on machines without the Lazarus IDE installed), by installing the libssl--dev package as suggested by all. In the case of Linux, I added three dependencies to my .deb distribution package (besides other already required by Lazarus applications): libssl (>=1.1.1), libssl-dev (>=1.1.1), openssl (>=1.1.1) I hope this will work on most distros. It looks that the problem is solved and this topic can now be closed. Thank you very much! With warmest regards, ---------------------------------------------------------------------- delphius · 2023-09-17 06:41 Quote from: delphius on September 16, 2023, 08:36:05 pmOK, but we have to remember what rvk explained above, that we can't just bring our own .so into a linux system by simply using them from a program folder, as they are themselves! depend on the specific! versions of other libraries, which usually does not happen in windows (except for dependencies on various runtimes). I looked at the dependencies of both dynamic libraries, except for mutual dependence and dependence on libc (on which the application binary itself depends too), there are no more dependencies.  Then the question is, what could be the problems with distribution? ---------------------------------------------------------------------- delphius · 2023-09-17 06:50 Quote from: maurobio on September 16, 2023, 10:07:02 pmIt looks that the problem is solved and this topic can now be closed. Great news! It's nice to hear that everything worked out! ---------------------------------------------------------------------- rvk · 2023-09-17 07:04 Quote from: delphius on September 17, 2023, 08:41:25 amThen the question is, what could be the problems with distribution?  Could you install libc6 if there is also a newer or older (g)libc installed? The symlink libc.so.6 to glibc would seem to always be there, so you might get away with this for now. Ok. How would you add you directory to the search path? You would need to add it to LD_LIBRARY_PATH to load the library. Make sure not to do that in .bashrc or somewhere else global because then every program is going to load your older openssl while some of those might need OpenSSL 3. It might be better and safer to use the .a option and link the openssl version statically into your program. ---------------------------------------------------------------------- delphius · 2023-09-17 07:29 Quote from: rvk on September 17, 2023, 09:04:30 amOk. How would you add you directory to the search path? You would need to add it to LD_LIBRARY_PATH to load the library. I don't need to add it to LD_LIBRARY_PATH because I forcibly loading them from program folder with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i InitSSLInterface(filepath + 'libssl' + ext, filepath + 'libcrypto' + ext); Quote from: rvk on September 17, 2023, 09:04:30 amMake sure not to do that in .bashrc or somewhere else global because then every program is going to load your older openssl while some of those might need OpenSSL 3. No global, nor touching anything outside program folder Quote from: rvk on September 17, 2023, 09:04:30 amIt might be better and safer to use the .a option and link the openssl version statically into your program. I have already said this above, that it would be ideal to encapsulate all dependencies inside the binary by static linking. This would simultaneously reduce both the volume of distribution (since static linking would take only the necessary parts, and not the entire volume of the library) so is the number of distribution units, reducing them to one (in the simplest case). And we have not yet touched on reducing the size of the binary by packers. P.S. further research led to the finding of a regular way to include the path of the initial search for shared libraries inside executable file, by passing to the linker -rpath or -R Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -rpath {path to lib(s) folder} for example for folder `lib` in current folder Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -rpath lib or for folder `lib` in program executable binary's folder (relative, in most cases we must use this method) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -rpath $ORIGIN/lib or for absolute path to folder `lib' (remember, when putting your shared libs to places where other programs can search of such libs, it can affect problems, we discussed above) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -rpath /usr/lib In order to pass this to the linker, it is necessary to set the appropriate parameter in the project properties in Lazarus (see attachment) In fpc, accordingly, you just need to pass the -k key with these parameters to the compiler At the output, we get in the executable file with readelf -d Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (RUNPATH) Library runpath: [lib]or Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (RUNPATH) Library runpath: [$ORIGIN/lib] Thus, in my opinion, this is an acceptable way to distribute the program together with shared libraries, without affecting the system environment and without affecting other programs. So if we want to distribute .so files in program folder, then we must set rpath just to $ORIGIN In case that for some reason the libraries in the specified folder are not found, then the search for shared libraries will follow the usual route. As for the versions of OpenSSL itself, as it was said, support for the 1.x branch ended on September 11, 2023, the 3.0.x branch is experiencing problems with speed, although it has a longer lifetime. Therefore, in my opinion, a reasonable choice would be to use the 3.1.x branch (currently the latest version 3.1.2). The most optimal would be to compile libssl.so.3 and libcrypto.so.3 from the library source codes yourself and rely on them when developing and testing your program. I am waiting for competent comments and opinions. ---------------------------------------------------------------------- paweld · 2023-09-17 14:00 I posted new version on github: https://github.com/paweld/especies    changes: - an entirely new Bio unit with threads (downloading infos and images in few threads), error handling, load from/save to json - adding error handling to httpclient - adding openssl3 unit to httpclient - libssl-dev installation is not required - few minor changes With support for threaded downloads, download times have been reduced by about 70%. ---------------------------------------------------------------------- maurobio · 2023-09-17 14:05 Hi, @paweld! Thank you very much for the updated code! I will study it in detail, to learn how things are done (in particular, I am not familiar with the use of threads). With warmest regards,