Recent

Author Topic: fphttpClient - problem in downloading file from dropbox  (Read 3538 times)

dbannon

  • Hero Member
  • *****
  • Posts: 1390
    • tomboy-ng, a rewrite of the classic Tomboy
Re: fphttpClient - problem in downloading file from dropbox
« Reply #15 on: August 30, 2019, 12:51:19 am »
OK, there must be varying degrees of this problem then.  Because for me, GetMem's fix solved the "hard ones" even on fpc304.  Maybe kjteng's issue is even harder still ?  Sigh ....

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

GetMem

  • Hero Member
  • *****
  • Posts: 3355
Re: fphttpClient - problem in downloading file from dropbox
« Reply #16 on: August 30, 2019, 07:05:46 am »
@kjteng
I did take another look...Your second link works fine, but you need the openssl libraries. In order for the first link to work, I had to modify fphttpclient.  As far as I can tell, now all three links works fine. Please test attached project.

PS: Don't forget to download the openssl libraries before testing.
32 bit: https://packages.lazarus-ide.org/openssl-1.0.2j-i386-win32.zip
64 bit: https://packages.lazarus-ide.org/openssl-1.0.2j-x64_86-win64.zip
Make sure the dlls are in the same folder as your exe.

kjteng

  • Full Member
  • ***
  • Posts: 194
Re: fphttpClient - problem in downloading file from dropbox
« Reply #17 on: August 31, 2019, 07:42:10 am »
@kjteng
I did take another look...Your second link works fine, but you need the openssl libraries. In order for the first link to work, I had to modify fphttpclient.  As far as I can tell, now all three links works fine. Please test attached project.

PS: Don't forget to download the openssl libraries before testing.
32 bit: https://packages.lazarus-ide.org/openssl-1.0.2j-i386-win32.zip
64 bit: https://packages.lazarus-ide.org/openssl-1.0.2j-x64_86-win64.zip
Make sure the dlls are in the same folder as your exe.
Yes! the modified fphttpClient works perfectly.  It even works for my original code (simply  InitSSLInterface ... httpclient.Get(url, localfile),  without setting SSLType and  httpHeader...).

Thank you very much.
« Last Edit: August 31, 2019, 07:47:19 am by kjteng »

ALAU2007

  • New Member
  • *
  • Posts: 11
Re: fphttpClient - problem in downloading file from dropbox
« Reply #18 on: April 25, 2021, 10:46:29 am »
Hi,

I have tested the Download.zip. It is fine when compile with Lazarus 1.6.4.

When it compiles with Lazarus 2.0.10, it gets 'Error:  Identifier not found "stTLSv1_2"'.   Any comments.

Thanks.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1469
  • Former Delphi 1-7, 10.2 user
Re: fphttpClient - problem in downloading file from dropbox
« Reply #19 on: April 25, 2021, 11:28:40 am »
It compiles for me (macOS) with Lazarus 2.0.10 and FPC 3.2.0 with no problems.

 "stTLSv1_2"' is in fpopenssl.pp
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65182 FPC 3.3.1 r49223 macOS 11.4 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

ALAU2007

  • New Member
  • *
  • Posts: 11
Re: fphttpClient - problem in downloading file from dropbox
« Reply #20 on: April 25, 2021, 01:37:27 pm »
Thanks,

I compiles in Windows 10.  I cannot locate the stTLSv1_2 in fpopenssl.pp.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1469
  • Former Delphi 1-7, 10.2 user
Re: fphttpClient - problem in downloading file from dropbox
« Reply #21 on: April 25, 2021, 01:54:27 pm »
I checked  "stTLSv1_2"' is in fpopenssl.pp in FPC 3.0.4, 3.2.0 and 3.3.1.

From FPC 3.2.0:

Code: Pascal  [Select][+][-]
  1. Constructor TSSLContext.Create(AType: TSSLType);
  2.  
  3. Var
  4.   C : PSSL_CTX;
  5.  
  6. begin
  7.   C := nil;
  8.   Case AType of
  9.     stAny:
  10.       begin
  11.         if Assigned(SslTLSMethod) then
  12.           C := SslCtxNew(SslTLSMethod)
  13.         else
  14.           C := SslCtxNew(SslMethodV23);
  15.       end;
  16.     stSSLv2: C := SslCtxNew(SslMethodV2);
  17.     stSSLv3: C := SslCtxNew(SslMethodV3);
  18.     stTLSv1: C := SslCtxNew(SslMethodTLSV1);
  19.     stTLSv1_1: C := SslCtxNew(SslMethodTLSV1_1);
  20.     stTLSv1_2: C := SslCtxNew(SslMethodTLSV1_2);
  21.   end;
  22.   if (C=Nil) then
  23.      Raise ESSL.Create(SErrCountNotGetContext);
  24.   Create(C);
  25. end;
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65182 FPC 3.3.1 r49223 macOS 11.4 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

Thaddy

  • Hero Member
  • *****
  • Posts: 10783
Re: fphttpClient - problem in downloading file from dropbox
« Reply #22 on: April 25, 2021, 02:29:31 pm »
Code: Pascal  [Select][+][-]
  1.     stSSLv2: C := SslCtxNew(SslMethodV2);
  2.     stSSLv3: C := SslCtxNew(SslMethodV3);
  3.     stTLSv1: C := SslCtxNew(SslMethodTLSV1);
???? These are all deprecated and no longer included in OpenSsl binaries.

You should not - can not - use them..(Unless you compile the OpenSsl binaries yourself, not recommended.)

Actually, the FPC bindings should also remove these protocols. In that sense it is a bug that such code is still there.

Also note the order is wrong: you need to test from high to low, not from low to high.
This goes for any mainstream Ssl library, not only OpenSsl.
In Essence, Ssl libraries do not contain Ssl  :D Only TLS 1.1 and higher.

The above lines are not even supported by any modern browser, not even recognized.
« Last Edit: April 25, 2021, 02:43:02 pm by Thaddy »

 

TinyPortal © 2005-2018