Recent

Author Topic: Why can't I get ssl to work????  (Read 607 times)

cdbc

  • Sr. Member
  • ****
  • Posts: 274
    • http://www.cdbc.dk
Why can't I get ssl to work????
« on: October 23, 2020, 06:02:33 pm »
Hello
I'm just dabbling with json, web and secure connections to learn a bit. But even a simple example ends with "Can't create ssl-context" error msg!
Have a look:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. var
  3.   S: string;
  4.   HTTP: TFPHttpClient;
  5. begin
  6.   HTTP:= TFPHttpClient.Create(nil);
  7.   try
  8.  
  9.     HTTP.AllowRedirect:= true;
  10.     HTTP.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');
  11.     S:= HTTP.Get('https://www.google.com');
  12.     Memo1.Lines.Text:= S;
  13.   finally HTTP.Free; end;
  14.  
We can agree, this is not rocket-science, what gives?!?
Running PcLinuxOs fully updated and the libraries are all there, should be a "Walk in the park" I'm a bit lost, please Help
Regards Benny

If it ain't broke, don't fix it ;)

sstvmaster

  • Full Member
  • ***
  • Posts: 176
Re: Why can't I get ssl to work????
« Reply #1 on: October 23, 2020, 06:44:14 pm »
Windows 10 (64 bit)
Lazarus: 2.0.10 / Trunk x32

cdbc

  • Sr. Member
  • ****
  • Posts: 274
    • http://www.cdbc.dk
Re: Why can't I get ssl to work????
« Reply #2 on: October 23, 2020, 08:33:29 pm »
Hello
I have. The example is from thaddy in that thread....
If it ain't broke, don't fix it ;)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1071
  • Former Delphi 1-7, 10.2 User
Re: Why can't I get ssl to work????
« Reply #3 on: October 24, 2020, 12:14:17 am »
FPC version? Operating system?
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

Handoko

  • Hero Member
  • *****
  • Posts: 3913
  • My goal: build my own game engine using Lazarus
Re: Why can't I get ssl to work????
« Reply #4 on: October 24, 2020, 04:17:17 am »
I modified wp's demo to make it work on my Ubuntu 19.10 Lazarus 2.0.10 by adding opensslsockets in the uses clause. It should be cross platform. As far as I know it requires at least FPC 3.2.0.

Try it:
« Last Edit: October 24, 2020, 04:18:50 am by Handoko »

cdbc

  • Sr. Member
  • ****
  • Posts: 274
    • http://www.cdbc.dk
Re: Why can't I get ssl to work????
« Reply #5 on: October 24, 2020, 05:08:54 am »
Hi
@trev:
PcLinuxOs fully updated
Lazarus version 2.0.4
Fpc version 3.0.4
Regards Benny
If it ain't broke, don't fix it ;)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1071
  • Former Delphi 1-7, 10.2 User
Re: Why can't I get ssl to work????
« Reply #6 on: October 24, 2020, 05:34:16 am »
SSL doesn't work in FPC 3.04 under Linux because it cannot find openSSL. You need FPC 3.2.0.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

cdbc

  • Sr. Member
  • ****
  • Posts: 274
    • http://www.cdbc.dk
Re: Why can't I get ssl to work????
« Reply #7 on: October 24, 2020, 10:50:02 am »
Hi
@trev: Thank you.
I'll get a hold of fpc 3.2.0, would that do the trick?
Regards Benny
If it ain't broke, don't fix it ;)

Handoko

  • Hero Member
  • *****
  • Posts: 3913
  • My goal: build my own game engine using Lazarus
Re: Why can't I get ssl to work????
« Reply #8 on: October 24, 2020, 02:25:45 pm »
The SSL - Linux issue already discussed and solved. You can search the forum if you want to find the information. But no need to do it. If I remember correctly this is the summary:

About a year ago, I was learning how to fetch data from http/https sites. Everything was good but after a Ubuntu update my code no longer worked. Not only me, many users have similar issue too.

Because the newer versions of Linux's kernel use newer SSL library and at that time FPC still used the older one, so all Lazarus/FPC Linux users had problem with SSL connection.

Many suggestions had been submitted. I tried them all but none of them worked on my tests. Until someone said the issue already fixed in FPC's trunk. So I waited and finally the Lazarus with FPC 3.2.0 released. I installed them and the SSL issue really has gone.

 

TinyPortal © 2005-2018