[fpc-pascal] HTTPS with fphttpclient
kristakis
pascal at nerd-net.com
Wed Aug 30 04:42:23 CEST 2017
Hi,
I'd like to make a request to a HTTPS address with TfpHTTPClient but am
getting an unknown protocol error.
I'm running fpc 2.6.4 on Rasbian 8 (Jessie) on a Pi 3. Here's the source
code:
program test2;
{$mode objfpc}{$H+}
uses
fphttpclient;
begin
WriteLn(TFPHTTPClient.SimpleGet('http://www.google.com/humans.txt'));
end.
That works fine but if I change the URL to https:// it returns:
An unhandled exception occurred at $00041AE4 :
EHTTPClient : Invalid protocol : "https"
Looking around on the internet led me to this mailing list where this
question has been answered before.
http://free-pascal-general.1045716.n5.nabble.com/https-how-does-it-work-td5727678.html#a5727837
"The ssockets unit has the ability to set up a TLS/SSL connection.
It uses openssl as a library.
You can check the fphttpclient unit to see how this is done. "
I found the source for fphttpclient at
https://github.com/alrieckert/freepascal/blob/master/packages/fcl-web/src/base/fphttpclient.pp
and it uses sslsockets unit. I found that at
https://github.com/graemeg/freepascal/tree/master/packages/fcl-net/src but
it wouldn't compile with the ssockets unit that I had. I tried the ssockets
unit on that same page and got more errors.
I tried to find all the units that were failing and replaced them with
copies from those githubs but ended up with just more errors further down
the uses tree. This didn't feel right so I reset and started over.
I found this post:
https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg38960.html
where the poster asks about https support in fphttpclient and is told:
It is already implemented in trunk. So you just:
program project1;
{$mode objfpc}{$H+}
uses
fphttpclient;
begin
WriteLn(TFPHTTPClient.SimpleGet('https://www.google.com/humans.txt'));
end.
This is pretty much what I had from the first search and I'm back to square
one. I feel like there's some simple little thing I'm missing but I have no
idea what it is. Is there a package for free pascal that I install via
apt-get that has the correct ssl units perhaps?
thanks,
kris
-----
Things I hate:
1. Forum signatures
2. Irony
3. Lists
--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
More information about the fpc-pascal
mailing list