Delphi Indy: Unable to load SSL libraries for the first time. Repeated work

I am using the latest sny snapshot (installed yesterday) and the latest SSL libraries.

When I try to send mail using idSMTP the first time I connect the component, I get an exception:

Failed to load SSL libraries

. It's funny that re-work is always. Debugging I found that the problem is in IsSSLOpenSSLHeader, Loaad function: boolean, line

@OpenSSL_add_all_algorithms := LoadFunctionCLib('OpenSSL_add_all_algorithms'); 

Why this happens not the first time, and not the second, still remains a mystery to me, but before I continue the investigation, I would like someone to know the solution to this problem.

+4
source share
2 answers

The code you use is NOT the last snapshot. This bug was fixed a couple of weeks ago. The line you specify is NOT in the last code, it has been replaced with the following:

 fn_OPENSSL_add_all_algorithms_noconf = 'OPENSSL_add_all_algorithms_noconf'; fn_OpenSSL_add_all_algorithms = 'OpenSSL_add_all_algorithms'; @OpenSSL_add_all_algorithms := LoadOldCLib(fn_OpenSSL_add_all_algorithms, fn_OPENSSL_add_all_algorithms_noconf); 
+5
source

I use Delphi XE-1 on Win 7/64, with SSL and Indy, which are installed by default. This week I had to work with SMTP and SSL, and I ran into the same issue you reported. Our application is somewhat complicated and already works and is deployed in several places, and it uses Indy at several points in the code, so installing a new version of Indy and rebuilding, etc. It was not very pleasant.

Since the problem only occurs in the first pass, I followed some of the code and came up with this simple, painless workaround:

  smtpClient.connect; smtpClient.disconnect; smtpClient.connect; if not smtpClient.Authenticate then raise ... smtpClient.Send(msg); 

As soon as you call connnect and then disconnect , the SSL libraries are loaded, so the second time you call connect you're good to go.

It works great.

0
source

Source: https://habr.com/ru/post/1303779/


All Articles