Thursday, 25 September 2014

"Cannot load SSL Library" using Delphi XE7

Delphi XE7 is using Indy version 10.6.0.5169 and if you want to use SSL components you now need to install OpenSSL. I'm using IdSSLIOHandlerSocketOpenSSL1 component for my FlickrPhotoStats application (you can read more about it here : Delphi REST client to retrieve flickr statistics ) that uses REST technology to retrieve flickr stats using the available API.

My tool used to work under Delphi XE6 without problems and after my upgrade to Delphi XE7 I can see that when it tries to use the IdHTTP component the following exception is thrown: "Cannot load SSL library". Basically the error is raised because now you need to install (*see comments below) you need to update OpenSSL as Delphi XE7 has a dependency with the latest library. Update it locally in your machine in order to use IndySSL components. At runtime, Indy loads two libraries: libeay32.dll and ssleay32.dll (these libraries are not distributed with Indy due to some restrictions exporting SSL technology). 


The easiest solution to fix this issue, is to download the following library:

This library among others can be found here: Win32OpenSSL.

NOTE: this solution is only applicable on Windows. I have only tested it under Windows 7 64 bits and it works fine.

Once the setup has been launched, select the following option:


After the libraries have been installed, the application will work without problems. DLLs can be found in the OpenSSL-Win32 directory also. With the selected option (Windows system directory) the libraries will be installed at C:\windows\SysWOW64 folder.

Update: KM mentioned that it's better to distribute the libraries with the app instead of installing the libraries under windows directory.

Update: Nicholas Ring has provided a very useful link for OpenDec (Home of OpenSSL DLLs & the Delphi Encryption Compendium), DLLs can be found here also:



If you are interested in my application, this can be found here:

Source code and binaries can be found here:

Screenshots:



11 comments:

  1. I get my OpenSSL DLLs from http://opendec.wordpress.com/, which is done by a person that also works on Indy

    ReplyDelete
    Replies
    1. Hi Nicholas,

      Thanks for the link! I will update my post.

      Jordi

      Delete
  2. I am the primary developer on Indy. The OpenSSL DLLs used in OpenDEC are downloaded from Indy's Fulgan mirror: http://indy.fulgan.com/SSL/ (which is linked to on the OpenDEC site). Indy's SSL implementation has relied primarily on OpenSSL for many years (though other third party SSL libraries can be plugged in to Indy), and that has always required the OpenSSL DLLs be present, either in the app folder or on the OS search path. Indy did not just start using OpenSSL in XE7, as this blog post suggests. What more likely caused the error is the XE7 version of Indy having a dependency on a newer version of OpenSSL than what you currently had installed on your machine, and the XE6 version of Indy not having that dependency. Indy has a WhichFailedToLoad() function that reports exactly which OpenSSL dependency is missing. If it reports anything other than the DLLs themselves then your DLLs are not up-to-date.

    ReplyDelete
    Replies
    1. Hi Remy,

      Thanks for your insights and useful comments. That's why posts like this are very useful as we get the correct response from the community. I will reflect the changes in the post with you info.

      Many thanks,
      Jordi

      Delete
  3. The OpenSSL DLLs are also available at http://indy.fulgan.com/SSL/ - this is next to the location for zipped nightly snapshot http://indy.fulgan.com/ZIP (which is linked from http://www.indyproject.org/Sockets/Download/DevSnapshot.aspx)

    ReplyDelete
    Replies
    1. Hi Mike,

      Thanks for your input, I will add it to the post also.

      Jordi

      Delete
  4. The OpenSSL DLLs are also available at http://indy.fulgan.com/SSL/ - this is next to the location for zipped nightly snapshot http://indy.fulgan.com/ZIP (which is linked from http://www.indyproject.org/Sockets/Download/DevSnapshot.aspx)

    ReplyDelete
  5. 1) Don't install in the Windows system directory. That is the OS private directory, don't mess there. Copy OpenSSL dlls into your application directory.
    2) Keep them updated - OpenSSL is under great scrutiny now and there will be a lot of fixes.
    3) Shining LIght OpenSSL distribution requires the Visual C++ runtime. Don't install the full OpenSSL SDK on machines that doesn't require it (use the Light version, if you choose this distribution).
    4) Indy project mirrors OpenSSL builds at http://indy.fulgan.com/SSL/. These doesn't require the runtime, and you just really need the two DLLs.

    ReplyDelete
    Replies
    1. Hi KM,

      I will do what you mention then. I can use the DLLs and use the light version of it.

      Jordi

      Delete
  6. Hi,
    I have downloaded from http://indy.fulgan.com/SSL/ and used OpenSSL dlls into my application directory. My system is windows 8.1 and using XE7. But SSL error is coming as "Could not load SSL library".

    ReplyDelete
    Replies
    1. Hi Santosh,

      Are you sure those dlls are placed where your executable is? and that the version matches with your executable (32 or 64 bits)?

      Cheers,
      Jordi

      Delete