SSL\TLS Client\Server lib based on Cryptlib Encryption Toolk

Share your advanced PureBasic knowledge/code with the community.
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by blueb »

Thanks xakep.

I got your code to run, but so far only getting debug messages:

Code: Select all

cl32.dll loaded
cl32 initialized
so I'm sure its something to do with the HTTP code.

The reason I'm commenting is your use of: Procedure ResolveFunc(BaseAddress.l, lpProcName.s)

It appears to be a generic function to search through the Ordinal Table of a DLL to search for the functions you want.
I haven't seen it done this way before. Thanks :)
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by cas »

blueb wrote:The reason I'm commenting is your use of: Procedure ResolveFunc(BaseAddress.l, lpProcName.s)

It appears to be a generic function to search through the Ordinal Table of a DLL to search for the functions you want.
I haven't seen it done this way before. Thanks :)
We have native function that does exactly that: GetFunction()
xakep
User
User
Posts: 40
Joined: Fri Mar 25, 2016 2:02 pm
Location: Europe

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by xakep »

@blueb You should use latest cryptlib available: https://www.cs.auckland.ac.nz/~pgut001/cryptlib/
There works fine on win 7 + PB 5.62 x86

@cas Yep, but GetFunction() won't work if you load the library via LoadLibrary( or any other way except of PB's OpenLibrary)
Fred
Administrator
Administrator
Posts: 16686
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by Fred »

Why is ResolvProc() needed in this case, instead of using GetProcAddress_() ?
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by blueb »

Thanks xakep... that solved it. :)
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
doctorized
Addict
Addict
Posts: 856
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by doctorized »

The TLS code works perfect but what about a server that requires authentication? How do we authenticate?

Also, very interesting for me, google server seems to support TLS v 1.0, 1.1, 1.2, but not 1.3, as cl32_cryptSetAttribute() succeeded with attribute values 1 to 3 but not succeded with 4 for v1.3 or 0 for TLS AUTO.
tatanas
Enthusiast
Enthusiast
Posts: 204
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: SSL\TLS Client\Server lib based on Cryptlib Encryption T

Post by tatanas »

I tryed the code with TLS_Talk("www.google.com", 443, Headers) and it works well.
Now I would like to do the same to make GET request on a web console management of a switch which use a self signed certificate (on my LAN). This certificate is already register in my certifcate windows store.
When I try the same code (replacing by the ip address of my switch), I've got an error with cl32_cryptSetAttribute(SessionId, #CRYPT_SESSINFO_ACTIVE, 1).
I suppose I should use some Certifcate function but I can't find which one.

Any idea ?
Windows 10 Pro x64
PureBasic 6.04 x64
Post Reply