OpenSSL Load Additional Functions

By Default Indy defines the most common openssl functions needed to encrypt the communications, but sometimes you need more functions for encryption, signing... From sgcIndy 2025.3.0 you can use the new method IdOpenSSLSetLoadFuncsCallback to assign a callback for loading additional OpenSSL functions dynamically.


IdOpenSSLSetLoadFuncsCallback

TIdLoadSSLFuncsCallback = procedure(hIdSSL: TIdLibHandle; hIdCrypto: TIdLibHandle; 
  const FailedLoadList: TStringList); 

This is a procedure type that serves as a callback, it takes three parameters:

  • hIdSSL: TIdLibHandle - Handle to the loaded SSL library.
  • hIdCrypto: TIdLibHandle - Handle to the loaded Crypto library.
  • FailedLoadList: TStringList - A list of functions that failed to load.


The purpose of this callback is to allow the user to perform custom processing when OpenSSL functions are being loaded, such as logging failed function loads or handling errors. 

IdOpenSSLSetUnLoadFuncsCallback

TIdUnLoadSSLFuncsCallback = procedure(); 

It serves as a callback for unloading SSL functions.This is useful for performing cleanup when OpenSSL libraries are being unloaded. 

How to load custom function

Find below a simple example of how to load the function EVP_PKEY_CTX_set_rsa_padding using the callbacks. 

var
  EVP_PKEY_CTX_set_rsa_padding : function(ctx: PEVP_PKEY_CTX; pad: Integer): Integer; cdecl;
  
procedure DoOpenSSLLoadFuncsCallback(hIdSSL: TIdLibHandle; hIdCrypto:
    TIdLibHandle; const FailedLoadList: TStringList);
begin
  @EVP_PKEY_CTX_set_rsa_padding := LoadLibFunction(hIdCrypto, 'EVP_PKEY_CTX_set_rsa_padding');
end;

procedure DoOpenSSLUnLoadFuncsCallback;
begin
  @EVP_PKEY_CTX_set_rsa_padding := nil;
end;

IdOpenSSLSetLoadFuncsCallback(DoOpenSSLLoadFuncsCallback);
IdOpenSSLSetUnLoadFuncsCallback(DoOpenSSLUnLoadFuncsCallback); 

Enter your text here ...

Delphi Demo

Find below a delphi demo showing how to load a custom openssl function using sgcIndy 2025.3.0+ 

sgcIndy_LoadCustomFunctions
3.2 mb
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

sgcWebSockets 2025.2

Related Posts