HTTPS Requests in FreeBasic

General FreeBASIC programming questions.
Post Reply
mvpimenta
Posts: 2
Joined: Mar 24, 2019 15:14

HTTPS Requests in FreeBasic

Post by mvpimenta »

Hi!!!

I have a project I´m doing in the office. There is an arduino (yes!!) colector machine that sends data using https-get (=parameters in url) to a cloud server. This request needs a 'fingerprint', based on server-cert to handshake the connection and allow connectivy to site. OK, it s working done...
This servers collect data (an url API entry-point) and persist them in a cloud database.
Other API returns a compiled data list, JSon formatted, when called (... over https, too).

I need to get these data and process in my FB program. I tried to use the examples (get-https, http-page etc) I saw here, and the FB-prog works perfectly over http (:80). But, when I try the https (:443), it doesn´t connect, don´t handshake, ... I think that I´ll need to pass other data (like the fingerprint or security-cert) to handshake and accept the connection - and the data can be requested and retrieved, like http.

Well: Are there a lib, function, include or example code to work with https protocol (TLS or SSL)?
I can´t work with 'wget', 'curl' executables, (to get the file, save to disk and after that, read it via "open ... as #1'), due the Sec.Info restrictions in office..

Could you help me?
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: HTTPS Requests in FreeBasic

Post by MrSwiss »

You probably need some libraries, which deal with SSL/TLS stuff.
(cyptographically secured connections)
See: OpenSSL.org

On the use of those lib's, you'll have to consult their Documentation,
since they're not part of FBC.
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: HTTPS Requests in FreeBasic

Post by St_W »

There's also a library-version of curl, libcurl, which provides an API that you can use directly in your application instead of running external applications. Dealing with SSL yourself can get quite complicated, so I strongly advice to use some library that handles this for you (like the one I mentioned).
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: HTTPS Requests in FreeBasic

Post by TJF »

For https protocol (port 443) I use Gio. Find a header file at https://github.com/DTJF/gir_headers/tree/master/Gir

Regards
FXG861
Posts: 89
Joined: Feb 01, 2009 17:10
Location: Canada

Re: HTTPS Requests in FreeBasic

Post by FXG861 »

St_W wrote:There's also a library-version of curl, libcurl, which provides an API that you can use directly in your application instead of running external applications. Dealing with SSL yourself can get quite complicated, so I strongly advice to use some library that handles this for you (like the one I mentioned).
Sorry to revive this thread but the subject fit exactly my problem.

I am trying to convert an old project because the HTTPS request not being handle correctly by TSNE.
(HTTP was ok but the site his now forcing HTTPS access)

I need to keep everything built-in (no external dll).
And i need to keep using the old version of freebasic (0.24)

So i am trying to upgrade from TSNE to Curl
But i am unable to use succesfully Curl without the use of the external "libcurl.dll"

I have downloaded the latest version from https://curl.se/download.html
I have copied "libcurl.a" and "libcurl.dll.a" under lib/Win32

What am i doing wrong ?
miilvyxg
Posts: 193
Joined: Dec 07, 2021 6:51

Re: HTTPS Requests in FreeBasic

Post by miilvyxg »

FXG861 wrote:
St_W wrote:There's also a library-version of curl, libcurl, which provides an API that you can use directly in your application instead of running external applications. Dealing with SSL yourself can get quite complicated, so I strongly advice to use some library that handles this for you (like the one I mentioned).
Sorry to revive this thread but the subject fit exactly my problem.

I am trying to convert an old project because the HTTPS request not being handle correctly by TSNE.
(HTTP was ok but the site his now forcing HTTPS access)

I need to keep everything built-in (no external dll).
And i need to keep using the old version of freebasic (0.24)

So i am trying to upgrade from TSNE to Curl
But i am unable to use succesfully Curl without the use of the external "libcurl.dll"

I have downloaded the latest version from https://curl.se/download.html
I have copied "libcurl.a" and "libcurl.dll.a" under lib/Win32

What am i doing wrong ?
Link it statically: https://stackoverflow.com/questions/324 ... statically
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: HTTPS Requests in FreeBasic

Post by St_W »

If your application is targeting Windows only (as you're talking about DLL files) you could also use some windows api instead of liburl, e.g. https://docs.microsoft.com/en-us/window ... net/portal
FXG861
Posts: 89
Joined: Feb 01, 2009 17:10
Location: Canada

Re: HTTPS Requests in FreeBasic

Post by FXG861 »

Thank you both for your suggestion.

My programs are DOS application that are making http Calls using Tsne (from ThePuppetMaster).
When i was doing windows application i was using "Window9" GUI library (from Vanya )

I don't want to redesign the programs.
I simply want to adjust them to work with Https.

Any support & Suggestion is always welcome !!!
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: HTTPS Requests in FreeBasic

Post by St_W »

Do your really mean DOS application? (typically compiled with FreeBasic for DOS and needing a DOS extender to run) or just a Windows Console application? (typically compiled with FreeBasic for Win32/Win64 and optionally "-s console" argument). If I remember correctly TSNE doesn't support DOS and thus I guess it's just a win32 console application. On Windows TSNE uses Windows' WinSock2 API as far as I know. I'd recommend replacing that by WinHTTP API (or the older WinInet API).

All three are included with any Windows version since 20 years (Windows 2000 and later), some even longer. Detailed documentation is available from Microsoft on MSDN:
WinSock2: https://docs.microsoft.com/en-us/window ... art-page-2
WinHTTP: https://docs.microsoft.com/en-us/window ... start-page
WinInet: https://docs.microsoft.com/en-us/window ... net/portal
FXG861
Posts: 89
Joined: Feb 01, 2009 17:10
Location: Canada

Re: HTTPS Requests in FreeBasic

Post by FXG861 »

Hi St_W,
You are right !!!
I ment Freebasic Windows 32 bits compiler, the application running inside a console window.
Sorry for the confusion.
Post Reply