Article View: borland.public.delphi.internet.winsock
Article #1Trying to download a file via https:
From: Daniel “Ico” Layne
Date: Fri, 16 Feb 2024 11:32
Date: Fri, 16 Feb 2024 11:32
109 lines
4470 bytes
4470 bytes
Trying to download a file via https
keep getting this error:
error:1408F10B:SSL routines:ssl3_get_record:wrong version number'.
Prozess httpsRequest.exe (10272)
I teted sslVersion and Method in all constellations but it doesent seem to work.
----
program HttpsHttpRequest;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes, IdHTTP, IdComponent, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdStack, IdGlobal,
IdSSLOpenSSL in 'openssl\IdSSLOpenSSL.pas',
IdSSLOpenSSLHeaders in 'openssl\IdSSLOpenSSLHeaders.pas',
uOpenSLLExt in 'openssl\uOpenSLLExt.pas';
procedure DownloadFile(const AHost: string; APort: Integer; const ADocument: string;
const AOutFile: string; ADebug: Boolean);
var
_IdHTTP: TIdHTTP;
_SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
_FileStream: TFileStream;
_Url: string;
begin
try
_IdHTTP := TIdHTTP.Create(nil);
_IdHTTP.HandleRedirects := true;
_SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(_IdHTTP);
try
{$IFDEF DEBUG}
while True do begin
sleep(100);
end;
{$ENDIF}
_IdHTTP.IOHandler := _SSLHandler;
if ADebug then
Writeln('---------- Debug AN ----------');
_Url := 'https://' + AHost + ':' + IntToStr(APort) + ADocument;
Writeln('Versuche Download von: ', _Url);
_FileStream := TFileStream.Create(AOutFile, fmCreate);
try
try
_IdHTTP.Get(_Url, _FileStream);
except
on E: EIdOSSLUnderlyingCryptoError do begin
Writeln(E.Message + #13#10);
Writeln('Fehler beim Herunterladen über HTTPS. Versuche HTTP...');
_IdHTTP.IOHandler := nil; // Setze den SSL-Handler zurück
_IdHTTP.Get('http://' + AHost + ':' + IntToStr(APort) + ADocument, _FileStream);
Writeln('---------------------------------------------------------------------');
end;
end;
finally
_FileStream.Free;
end;
Writeln('Download erfolgreich. Gespeichert unter: ', ExtractFilePath(AOutFile));
finally
_SSLHandler.Free;
end;
except
on E: Exception do begin
Writeln('Fehler: ' + #13#10 + E.Message);
end;
end;
_IdHTTP.Free;
end;
var
_Host, _Document, _OutFile: string;
_Port: Integer;
_Debug: Boolean;
begin
try
if ParamCount <> 5 then begin
Writeln('Usage: HttpsHttpRequest host port document outfile debug');
Halt(1);
end;
_Host := ParamStr(1);
_Port := StrToInt(ParamStr(2));
_Document := ParamStr(3);
_OutFile := ParamStr(4);
_Debug := StrToBool(ParamStr(5));
DownloadFile(_Host, _Port, _Document, _OutFile, _Debug);
except
on E: Exception do begin
Writeln('Error: ' + E.Message);
Halt(1);
end;
end;
end.
Technical Details
Message-ID:
<46e2840b-806c-4d40-83c5-3d5a798567edn@googlegroups.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf1.newsdeef.eu!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <46e2840b-806c-4d40-83c5-3d5a798567edn@googlegroups.com> Subject: Trying to download a file via https: Date: Fri, 16 Feb 2024 11:32:52 +0000 From: Daniel “Ico” Layne <s4tzumi@gmail.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf1.newsdeef.eu!not-for-mail X-Forwarded-Encrypted: i=1; AJvYcCUvewMckEoK+y+D62cs/Brudc41JIkVhkuBwaduS605Scqpu2kRq+D22NOM1pI/3ZJbfG9E3qoG1eytmqCE6LjqqeGDamxSgvvcB9JTD49kM/Q2NSUY2DgmDkvsoLW5EvuVphF11EKNMRK2 X-Forwarded-Encrypted: i=1; AJvYcCUBS4T8El1WYOglw1kzglDRqh8990DbgGfw0lWn2FqPbKEFynALcjOdVhJns+n/xlnEDcDezfwPIzpa8PZo0RvJNKlvUfLtu4CxPvdN/AM7AL88YftEGBxecxWgK2KyIcJCmpNpa3WkWQ== X-Received: by 2002:ac8:7f87:0:b0:42c:4c55:3fa5 with SMTP id z7-20020ac87f87000000b0042c4c553fa5mr206518qtj.10.1708083173358; Fri, 16 Feb 2024 03:32:53 -0800 (PST) X-Received: by 2002:a05:6870:4413:b0:21e:3ffe:94f1 with SMTP id u19-20020a056870441300b0021e3ffe94f1mr149177oah.0.1708083173043; Fri, 16 Feb 2024 03:32:53 -0800 (PST) Newsgroups: borland.public.delphi.internet.winsock Injection-Info: google-groups.googlegroups.com; posting-host=109.43.50.195; posting-account=e7lEkAoAAADPvixMUFRaX19Y6Z2raJKD Nntp-Posting-Host: 109.43.50.195 User-Agent: G2/1.0 Mime-Version: 1.0 Injection-Date: Fri, 16 Feb 2024 11:32:53 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable