Jump to content
danielKishlakov

Indy OpenSSL static linking

Recommended Posts

Hi) I need to statically link an existing Delphi app that uses Indy for networking with OpenSSL 1.0.2u.

From the Indy code itself and some online resources I can see that Indy is capable of somehow statically linking with OpenSSL.

But given Delphi can't link .lib files I try to figure out how do I build OpenSSL in a single object file so I can link it to the project.

By now I've managed to compile it into a single obj by #including all the relevant source files into a single file.

I made it compile by ifdefing certain structs in the code, got rid of macro redefinition warnings, solved the case insensitive linking issues and finally linked it to the project.

But now I keep getting very weird errors, like e.g. call to CRYPTO_free yields access violation error and such.

So obviously what I'm doing is more of a hack and it's probably wrong.

I know that there has to be a way of doing it properly, could someone please direct me to the way it's supposed to be done.

 

System: Windows 10 x64, RAD Studio Tokyo 10.2, I compile OpenSSL with MSVC for x64

Edited by danielKishlakov

Share this post


Link to post
7 hours ago, danielKishlakov said:

But given Delphi can't link .lib files I try to figure out how do I build OpenSSL in a single object file so I can link it to the project.

By now I've managed to compile it into a single obj by #including all the relevant source files into a single file.

As I mentioned earlier to your comment on StackOverflow, you can't do it that way:

Quote

I can tell you, though, that including .c files in other .c files is definitely wrong. Make a project, add the .c files to the project, then compile the project.

 

Share this post


Link to post

There is a commercial solution to statically linking OpenSSL with three different Delphi internet components from https://www.yunqa.de/delphi/products/openssl/index

 

But they don't support OpenSSL 1.0.2 which is long obsolete and has no recent security fixes.  But YuOpenSSL includes a new Indy OpenSSL 1.1.1 IOHandler so it can handle TLSv1.3 and YuOpenSSL supports OpenSSL 3.0 for ICS. 

 

Angus

 

Share this post


Link to post
2 hours ago, Angus Robertson said:

There is a commercial solution to statically linking OpenSSL with three different Delphi internet components from https://www.yunqa.de/delphi/products/openssl/index

FYI, that is already on Indy's radar: #410 Support YuOpenSSL

2 hours ago, Angus Robertson said:

But YuOpenSSL includes a new Indy OpenSSL 1.1.1 IOHandler so it can handle TLSv1.3 and YuOpenSSL supports OpenSSL 3.0 for ICS.

Since the migration path from OpenSSL 1.1.1 to 3.0 is fairly minimal, I wonder why they don't support 3.0 for Indy.

Share this post


Link to post
12 hours ago, Remy Lebeau said:

FYI, that is already on Indy's radar: #410 Support YuOpenSSL

I only can see that YuOpenSSL support Win32/64, is that correct ?

I wonder why, since a fully compiled SSL should be running under all platforms as well, or do they use any platform specific stuff of Windows only ?

Edited by Rollo62

Share this post


Link to post

YuOpenSSL is supplied as dozens of compiled DCUs for Delphi 6 and later, with Win32 and Win64 versions. 

 

I'm told a lot of preprocessing of the original OpenSSL code is required before it will compile, for instance there is heavy use of macro expansion statements that need converting into pure C.  But this is automated, and new versions of YuOpenSSL usually appear within hours of a new OpenSSL release, one is due next week. 

 

The original OpenSSL can be built for multiple platforms, but I guess doing so for Delphi is a commercial decision, depending on demand.  

 

BTW, I'm just a YuOpenSSL user, it's not my project. 

 

Angus

 

Share this post


Link to post

YuOpenSSL seems to be very interesting, but if they stop at Windows that wouldn't make much sense nowadays.

 

Not sure what you mean by "preprocessing", so does that mean the library is not a pure Delphi-Pascal port ( what it claims to be, IMHO ),

but rather a kind of OpenSSL "transpiler", including macros and C code, that is generating a binary DCU magically.

It says at YuOpenSSL that you can get the sources as well, so I hope you talk about the process at YuOpenSSL to generate Pascal sources here, not about what a client has to do with the sources.

 

 

 

Edited by Rollo62

Share this post


Link to post

YuOpenSSL is C code compiled into a Delphi DCU, it is not a translation of C to pascal code.  There are several other C libraries similarly built into Delphi, like ZLIB.  

 

But you can not just download OpenSSL from Github and compile it for Delphi, some magic is required, and that required a lot of effort to achieve. 

 

Angus

 

Edited by Angus Robertson

Share this post


Link to post

Ok, thats a pity.

Then I have little hope that it will be cross-platform one day.

Maybe porting and testing the 3500+ functions of OpenSSL to Delphi native is a too tough beast, I had hope that Yu was doing it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×