Einzelnen Beitrag anzeigen

Benutzerbild von wjjw
wjjw

Registriert seit: 3. Aug 2017
Ort: Wiener Neustadt, Österreich
75 Beiträge
 
Delphi 12 Athens
 
#7

AW: Datasnap/SSL/Zertifikate mit Delphi 10.3.3

  Alt 26. Nov 2019, 19:03
Hab das Problem gefunden (im Delphi Code: IdSSLOpenSSL.by_Indy_unicode_file_ctrl(...))
Kann mir diesen Code jemand erklären?
Und das Lustige ist, das es der Programmierer sogar kommentiert hat..

Delphi-Quellcode:
function by_Indy_unicode_file_ctrl(ctx: PX509_LOOKUP; cmd: TIdC_INT;
  const argc: PAnsiChar; argl: TIdC_LONG; out ret: PAnsiChar): TIdC_INT; cdecl;
var
  LOk: TIdC_INT;
  LFileName: String;
begin
  LOk := 0;
  case cmd of
    X509_L_FILE_LOAD:
      begin
        case argl of
          X509_FILETYPE_DEFAULT:
            begin
              LFileName := GetEnvironmentVariable
                (String(X509_get_default_cert_file_env));
              if LFileName <> 'then begin
                LOk := Ord(Indy_unicode_X509_load_cert_crl_file(ctx, LFileName,
                  X509_FILETYPE_PEM) <> 0);
              end else begin
                LOk := Ord(Indy_unicode_X509_load_cert_crl_file(ctx,
                  String(X509_get_default_cert_file), X509_FILETYPE_PEM) <> 0);
              end;
              if LOk = 0 then begin
                X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS);
              end;
            end;
          X509_FILETYPE_PEM:
            begin
              // Note that typecasting an AnsiChar as a WideChar is normally a crazy
              // thing to do. The thing is that the OpenSSL API is based on ASCII or
              // UTF8, not Unicode and we are writing this just for Unicode filenames.

              LFileName := PWideChar(argc); // <==================== HIER !!!!????? Warum nicht einfach LFileName :=argc;

              LOk := Ord(Indy_unicode_X509_load_cert_crl_file(ctx, LFileName,
                X509_FILETYPE_PEM) <> 0);
            end;
        else
          LFileName := PWideChar(argc);
          LOk := Ord(Indy_unicode_X509_load_cert_file(ctx, LFileName, TIdC_INT(argl)) <> 0);
        end;
      end;
  end;
  Result := LOk;
end;
Werner Weiß
--
Werner
  Mit Zitat antworten Zitat