$ cat a.pas
uses fphttpclient;
procedure test;
var
cli: TFPHTTPClient = nil;
begin
cli := TFPHTTPClient.Create(nil);
try
cli.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');
cli.Get('https://api.github.com/users/defunkt');
finally
cli.free;
end;
end;
begin
test();
end.
$ fpc -S2 a.pas
Hint: End of reading config file /etc/fpc.cfg
Target OS: Linux for x86-64
Compiling a.pas
Linking a
a.pas(18,1) Warning: "crtbegin.o" not found, this will probably cause a linking failure
a.pas(18,1) Warning: "crtend.o" not found, this will probably cause a linking failure
19 lines compiled, 0.4 sec
2 warning(s) issued
1 hint(s) issued
$ ./a
{"login":"defunkt","id":2,"node_id":"MDQ6VXNlcjI=","avatar_url":"https://avatars0.githubusercontent.com/u/2?v=4","gravatar_id":"","url":"https://api.github.com/users/defunkt","html_url":"https://github.com/defunkt","followers_url":"https://api.github.com/users/defunkt/followers","following_url":"https://api.github.com/users/defunkt/following{/other_user}","gists_url":"https://api.github.com/users/defunkt/gists{/gist_id}","starred_url":"https://api.github.com/users/defunkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/defunkt/subscriptions","organizations_url":"https://api.github.com/users/defunkt/orgs","repos_url":"https://api.github.com/users/defunkt/repos","events_url":"https://api.github.com/users/defunkt/events{/privacy}","received_events_url":"https://api.github.com/users/defunkt/received_events","type":"User","site_admin":true,"name":"Chris Wanstrath","company":"@github ","blog":"http://chriswanstrath.com/","location":"San Francisco","email":null,"hireable":null,"bio":"🍔 ","public_repos":107,"public_gists":273,"followers":20407,"following":210,"created_at":"2007-10-20T05:24:19Z","updated_at":"2018-08-15T02:05:37Z"}
A simple request gives the error "ESSL, Failed to create SSL context".
The original code, one unit added, openssl version is 1.1.1c
program Project1; {$mode delphi} uses opensslsockets,fphttpclient; procedure test; var cli: TFPHTTPClient = nil; begin cli := TFPHTTPClient.Create(nil); try cli.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)'); cli.Get('https://api.github.com/users/defunkt'); finally cli.free; end; end; begin test(); end.
Works like a charm
Hi,
Try this:
HttpClient.OnGetSocketHandler:=HttpClientGetSocketHandler;
......
procedure TForm1.HttpClientGetSocketHandler(Sender: TObject;
const UseSSL: Boolean; out AHandler: TSocketHandler);
begin
If UseSSL then begin
AHandler:=TSSLSocketHandler.Create;
TSSLSocketHandler(AHandler).SSLType:=stTLSv1_1; // <--
end else begin
....
end;
end;
uses opensslsockets,fphttpclient;Translated is "Cant' found opensslsockets used from httpget"
Adding "ssockets" at uses, now seems works fine.
HttpClient.OnGetSocketHandler:=HttpClientGetSocketHandler;
......
It is in trunk fpc codeuses opensslsockets,fphttpclient;Translated is "Cant' found opensslsockets used from httpget"
Adding "ssockets" at uses, now seems works fine.
I also cannot find the opensslsockets unit that Thaddy mentions. It does not appear on wiki, its not in the online package manager, just where does it come from ?
...It is in trunk fpc code
I also cannot find the opensslsockets unit that Thaddy mentions. It does not appear on wiki, its not in the online package manager, just where does it come from ?