Page 1 of 1

TLS socket connection in Xbase 1.9

Posted: Thu May 26, 2022 11:02 am
by SlavkoDam
Hello,
In Xbase 2.0 socket functions work for both non-TLS and TLS connections. They work fine for any Internet protocol.
In Xbase 1.9 socket functions work fine only for non-TLS connections. TLS connection is created successfully, but on ClientHello message, TLS server always returns alert error 50, which is decode error.
Also, in Xbase 2.0 socket descriptors have 8 digits and in Xbase 1.9 they have 3-4 digits.
I use the same socket functions both in Xbase 1.9 and Xbase 2.0.
Does anybody knows what is the difference, and what I did wrong or miss?

Thanks.

Re: TLS socket connection in Xbase 1.9

Posted: Fri May 27, 2022 1:08 am
by Tom
You will need Xb2.Net (prof) in a later version to do this - or switch to 2.0. Xbase++ 1.9 doesn't support SSL/TLS.

Re: TLS socket connection in Xbase 1.9

Posted: Fri May 27, 2022 11:49 am
by SlavkoDam
Hi Tom,
Yes, I know that Xbase 1.9 don't support TLS. In order to overcome that lack for Xbase 1.9 users, I developed my own implementation of WinSock2, and it works o.k. but only for non-TLS as in Xbase 1.9. The point is that the base socket should be set to security state to work for TLS. There are several methods to do that. I tried the basic one, but without results.
Xb2.Net uses OpenSSL for TLS connection and communication. I don't need that because I have developed my own TLS implementation, and it works fine in Xbase 2.0, because in it the sockets are secured.
I have to try some other options for securing sockets.

Regards

Re: TLS socket connection in Xbase 1.9

Posted: Thu Jun 02, 2022 11:28 am
by SlavkoDam
The problem is solved. I was not the problem in socket, but in Xbase++ function RandomKey() which return empty value in 1.9. I created my own function for that purpose in C using WinApi, and now TLS client works fine. All Internet clients in Xbase++ 1.9 now support TLS connection.

Re: TLS socket connection in Xbase 1.9

Posted: Fri Jun 03, 2022 4:33 pm
by rdonnay
That is good information for 1.9 users.
It probably could have been written in Xbase++ too, for those 1.9 users who can't program C.

Re: TLS socket connection in Xbase 1.9

Posted: Sat Jun 04, 2022 7:42 am
by SlavkoDam
Random key generation can be simulated in Xbase++ code with STRTRAN(UUIDTOCHAR(UUIDCREATE()), "-", ""), but this returns key of length 16. For larger keys the same code can be repeated in a loop, concatenated the results, and SUBSTR() it to the right length.

Re: TLS socket connection in Xbase 1.9

Posted: Sat Jun 04, 2022 5:03 pm
by Auge_Ohr
hi,

"how" have you integrate "C"-Code to Xbase++ :?:
can you please post some "C"-Code Sample for Xbase++

p.s. under harbour i can make COM DLL so i can use it as ActiveX

Re: TLS socket connection in Xbase 1.9

Posted: Sat Jun 04, 2022 11:23 pm
by SlavkoDam
Hi,
I use Xbase++ C-API extension, which is part of Xbase++ package. It works great and have many capabilities, especially for sending parameters to C function and retrieving results from it. You can create a C DLL file and link it with your app, or just a C object files and link it with Xbase++ object files. I personally create a C DLL file, don't like to mix different code files.
There is one simple example in Xbase++ C-API documentation. It shows how to make both version of integration. I tested it and it works fine.