Recent

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

cdbc

  • Hero Member
  • *****
  • Posts: 995
    • 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 ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: Why can't I get ssl to work????
« Reply #1 on: October 23, 2020, 06:44:14 pm »
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

cdbc

  • Hero Member
  • *****
  • Posts: 995
    • 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 ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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?

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • 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

  • Hero Member
  • *****
  • Posts: 995
    • 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 ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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.

cdbc

  • Hero Member
  • *****
  • Posts: 995
    • 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 ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • 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