By Default Indy defines the most common openssl functions needed to encrypt the communications, but sometimes you need more functions for encrypt, signing... you can use the method IdOpenSSLSetLoadFuncsCallback to assign a callback for loading additional OpenSSL functions dynamically.
TIdLoadSSLFuncsCallback = procedure(hIdSSL: TIdLibHandle; hIdCrypto: TIdLibHandle; const FailedLoadList: TStringList);
This is a procedure type that serves as a callback, it takes three parameters:
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.
TIdUnLoadSSLFuncsCallback = procedure();
It serves as a callback for unloading SSL functions.This is useful for performing cleanup when OpenSSL libraries are being unloaded.
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);