Einzelnen Beitrag anzeigen

christophspaeth

Registriert seit: 7. Mär 2008
73 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Workaround/Hack: OpenSSL 1.0.2g mit altem Indy

  Alt 16. Mär 2016, 16:54
Hallo,
wie in http://www.delphipraxis.net/1332882-post49.html nachzulesen ist, funktionieren ältere Indy-Versionen nicht mit OpenSSL 1.0.1s / 1.0.2g.

Nachdem nicht zu jedem Zeitpunkt "mal eben" ein Wechsel der Indy-Version möglich ist, habe ich einen Hack geschrieben, der die Überprüfung "austrickst", aber eigentlich nur das fehlen von SSLv2_* kaschieren sollte.

Diese Unit muss lediglich in das Projekt aufgenommen werden. Für meinen Zweck funktioniert sie, wenn jemand Bedenken hat oder Gefahren sieht, freue ich mich über Feedback.

Die Logik befindet sich komplett im initialzation-Teil, es gibt also noch kein Exception-Handling.
Verwendung wie üblich auf eigene Gefahr.

Delphi-Quellcode:
unit IdOpenSSLHack_SSLv2;

interface
uses
  Classes,
  IdSSLOpenSSLHeaders;

implementation
var
  FFailedFunctionLoadList: TStringList;
  I: Integer;

initialization
  // hack to not fail with openSSL 1.0.2g (SSLv2 functions disabled)

  // first manually load the headers. his function will do the check for the
  // existance of the imported functions only once. So further (atomatic or manual)
  // calls e.g. via LoadOpenSSLLibrary or by creating an SSL Context get a true
  // from this call.
  IdSSLOpenSSLHeaders.Load();

  // now check that only the SSLv2_ functions are missing. Unload lib otherwise
  // to re-enable the check (not required when handle is 0)
  if IdSSLOpenSSLHeaders.GetCryptLibHandle <> 0 then
  begin
    FFailedFunctionLoadList := TStringList.Create();
    FFailedFunctionLoadList.CommaText := IdSSLOpenSSLHeaders.WhichFailedToLoad();
    // any functin startting with SSLv2_ may be missing, unload otherwise
    for I := 0 to FFailedFunctionLoadList.Count - 1 do
    begin
      if pos('SSLv2_', FFailedFunctionLoadList[I]) <> 1 then
      begin
        // unload again - we should get the "normal" check
        IdSSLOpenSSLHeaders.Unload();
        break;
      end;
    end;
    FFailedFunctionLoadList.Free;
  end;
end.
Christoph Späth
  Mit Zitat antworten Zitat