"no OPENSSL_Applink " in OpenSSL3.0.5

Matt Caswell matt at openssl.org
Fri Aug 12 09:59:55 UTC 2022

On 12/08/2022 03:34, Imazu Setsuo wrote:
> On 2022/08/10 18:44, Matt Caswell wrote:
>> On 10/08/2022 00:11, Imazu Setsuo wrote:
>>> Hello, my name is Imazu.
>>> I am using OpenSSL3.0.5 to develop a windows program.
>>> When I call PEM_read_PrivateKey() I get the following error:
>>> OPENSSL_Uplink(00007FF8011DD3E0,08): no OPENSSL_Applink
>>> The source that calls PEM_read_PrivateKey() includes the following 
>>> sources.
>>> #include <openssl/applink.c>
>>> In the test program
>>> test.exe --> my_appl.dll --> openssl.dll
>>> , the above include is the source in my_appl.dll.
>>> The depends tool (Dependency Walker) can check the entry of
>>> OPENSSL_Applink.
>>> By the way, if you describe "#include <openssl/applink.c>" in the source
>>> inside test.exe, it will work.
>>> However, I want to complete the processing within my_appl.dll.
>>> Please tell me a good way.
>>> Best regards.
>> The problem comes when your code opens a FILE* and then passes it for
>> use to OpenSSL. If your code and OpenSSL are using a different C runtime
>> then that's going to fail.
>> A possible workaround is not call PEM_read_PrivateKey() at all and
>> instead use PEM_read_bio_PrivateKey(). You can then (for example) load
>> the file into memory completely within your code and store the data in a
>> mem BIO (e.g. using BIO_new_mem_buf()). This removes the need to pass
>> FILE * pointers from one dll to another and avoids the problem.
>> Matt
> hello.
> After fixing it with your advice, it worked without any errors.  Thank you.
> I've been thinking about this for a while, what do you think of the 
> following?
> The "HMODULE hModule" that can be referenced by DllMain is retained in 
> the variable (BASE_HANDLE) when the "DLL_PROCESS_ATTACH" condition occurs.

There'd probably have to be some call from the DLL into libcrypto 
providing the HMODULE handle to use....but then what happens if the end 
application is *also* using OpenSSL??

I suspect there is no good answer here.


More information about the openssl-users mailing list