Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Workaround/Hack: OpenSSL 1.0.2g mit altem Indy (https://www.delphipraxis.net/188569-workaround-hack-openssl-1-0-2g-mit-altem-indy.html)

christophspaeth 16. Mär 2016 16:54

Workaround/Hack: OpenSSL 1.0.2g mit altem Indy
 
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.


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:02 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz