-
Nov 29th, 2024, 03:31 PM
#1
Thread Starter
Hyperactive Member
Any way to use libssl-3.dll in VB6?
I'm working on a weird project for WinXP, I need modern SSL for my project and best I could find was libssl, it has modern OpenSSL, and is perfect. but I still couldnt figure out how to use it. it is not documented anywhere!
Code:
Private Declare Function SSL_library_init Lib "libssl-3.dll" () As Long
Private Declare Function SSLv23_client_method Lib "libssl-3.dll" () As Long
Private Declare Function SSL_CTX_new Lib "libssl-3.dll" (ByVal method As Long) As Long
Private Declare Function SSL_CTX_free Lib "libssl-3.dll" (ByVal ctx As Long) As Long
Private Declare Function SSL_new Lib "libssl-3.dll" (ByVal ctx As Long) As Long
Private Declare Function SSL_set_fd Lib "libssl-3.dll" (ByVal ssl As Long, ByVal fd As Long) As Long
Private Declare Function SSL_connect Lib "libssl-3.dll" (ByVal ssl As Long) As Long
Private Declare Function SSL_read Lib "libssl-3.dll" (ByVal ssl As Long, ByVal buf As String, ByVal num As Long) As Long
Private Declare Function SSL_write Lib "libssl-3.dll" (ByVal ssl As Long, ByVal buf As String, ByVal num As Long) As Long
Private Declare Function SSL_shutdown Lib "libssl-3.dll" (ByVal ssl As Long) As Long
Private Declare Function SSL_free Lib "libssl-3.dll" (ByVal ssl As Long) As Long
Private Declare Function ERR_get_error Lib "libssl-3.dll" () As Long
Private Declare Function ERR_error_string Lib "libssl-3.dll" (ByVal e As Long, ByVal buf As String) As String
Sub MakeHttpsRequest()
Dim ctx As Long
Dim ssl As Long
Dim result As Long
Dim buffer As String
Dim errorMsg As String * 256
' Initialize the SSL library
Call SSL_library_init
' Create a new SSL context
ctx = SSL_CTX_new(SSLv23_client_method())
If ctx = 0 Then
MsgBox "Failed to create SSL context"
Exit Sub
End If
' Create a new SSL connection
ssl = SSL_new(ctx)
If ssl = 0 Then
MsgBox "Failed to create SSL connection"
SSL_CTX_free (ctx)
Exit Sub
End If
' Set the file descriptor (fd) for the SSL connection
' Example socket descriptor is 0 for simplicity
result = SSL_set_fd(ssl, 0) ' Replace 0 with your socket descriptor
If result = 0 Then
MsgBox "Failed to set file descriptor for SSL connection"
SSL_free (ssl)
SSL_CTX_free (ctx)
Exit Sub
End If
' Perform SSL handshake and connect
result = SSL_connect(ssl)
If result <> 1 Then
result = ERR_get_error()
errorMsg = ERR_error_string(result, errorMsg)
MsgBox "SSL connect failed: " & errorMsg
SSL_free (ssl)
SSL_CTX_free (ctx)
Exit Sub
End If
' Write data to the SSL connection
buffer = "GET / HTTP/1.1" & vbCrLf & "Host: example.com" & vbCrLf & vbCrLf
result = SSL_write(ssl, buffer, Len(buffer))
If result <= 0 Then
result = ERR_get_error()
errorMsg = ERR_error_string(result, errorMsg)
MsgBox "SSL write failed: " & errorMsg
End If
' Read response from the SSL connection
buffer = String(1024, Chr(0))
result = SSL_read(ssl, buffer, Len(buffer))
MsgBox Left(buffer, result)
' Shutdown and free the SSL connection
SSL_shutdown (ssl)
SSL_free (ssl)
SSL_CTX_free (ctx)
End Sub
Private Sub Command1_Click()
MakeHttpsRequest
End Sub
Best I could write was this but it says
ERR:453
Can't find entry point SSL_library_init
It often means that SSL_library_init doesn't exist in the DLL. but does anybody know a way to use it? I couldn't find documentations!
-
Nov 29th, 2024, 03:37 PM
#2
Fanatic Member
Re: Any way to use libssl-3.dll in VB6?
If your goal is to connect to HTTPS sites, try the sample here:
https://www.vbforums.com/showthread....=1#post5661169
OpenSSL is poorly documented.
-
Nov 29th, 2024, 03:42 PM
#3
Thread Starter
Hyperactive Member
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by qvb6
Agreed, OpenSSL isn't even documented for Windows version at all. thanks for the link.
-
Nov 29th, 2024, 03:43 PM
#4
Thread Starter
Hyperactive Member
Re: Any way to use libssl-3.dll in VB6?
I will return back upon testing that ActiveX.
-
Nov 29th, 2024, 03:53 PM
#5
Fanatic Member
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by gaouser
I will return back upon testing that ActiveX.
It's part of Windows, so nothing to deploy, and it's easy to use.
-
Nov 29th, 2024, 05:06 PM
#6
Re: Any way to use libssl-3.dll in VB6?
Did you use a PE info program to see if it's in fact exported?
-
Nov 29th, 2024, 06:54 PM
#7
Re: Any way to use libssl-3.dll in VB6?
libcurl has fairly easy to use high level wrappers around it for https traffic
-
Nov 29th, 2024, 07:35 PM
#8
Re: Any way to use libssl-3.dll in VB6?
The documentation says "The SSL_library_init() and OpenSSL_add_ssl_algorithms() functions were deprecated in OpenSSL 1.1.0 by OPENSSL_init_ssl()."
So it's unsurprising something deprecated in v1.1 is now gone in 3.x
OPENSSL_init_ssl is an export of the libssl-3 (OpenSSL 3.4) build I found from last month, while SSL_library_init isn't.
Another thing to watch out for is a lot of these builds are _cdecl; you'll want to find out for sure about the one you're using. If it is you'll need to add the CDecl keyword and install The trick's VBCDeclFix addin or use tB instead.
Last edited by fafalone; Nov 29th, 2024 at 07:38 PM.
-
Nov 30th, 2024, 03:39 AM
#9
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by gaouser
I'm working on a weird project for WinXP, I need modern SSL for my project and best I could find was libssl, it has modern OpenSSL, and is perfect.
Btw, did you try using libssl-3.dll under XP? Latest version has Subsystem Version: 6.0 flagged in PE header but XP supports up to 5.01 so this will not run on XP.
It's weird that you couldn't find VbAsyncSocket project googling for modern TLS on XP using VB6. It supports TLS 1.3 and 1.2 on NT 4.0/Win98 and later with no external dependency and includes precompiled HttpRequest.DLL which you can use as a binary reference if you insist on using DLLs in your project.
This ActiveX DLL (not Std-DLL and no Declare Functions needed) has an WinHTTP Request Object replacement class so the methods/properties should be familiar and self-explanatory. There is always an option to directly include project's VB6 source files in your project if you don't want to ship/register extra DLL on client machines.
cheers,
</wqw>
-
Dec 1st, 2024, 10:09 AM
#10
Thread Starter
Hyperactive Member
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by wqweto
Btw, did you try using libssl-3.dll under XP? Latest version has Subsystem Version: 6.0 flagged in PE header but XP supports up to 5.01 so this will not run on XP.
It's weird that you couldn't find VbAsyncSocket project googling for modern TLS on XP using VB6. It supports TLS 1.3 and 1.2 on NT 4.0/Win98 and later with no external dependency and includes precompiled HttpRequest.DLL which you can use as a binary reference if you insist on using DLLs in your project.
This ActiveX DLL (not Std-DLL and no Declare Functions needed) has an WinHTTP Request Object replacement class so the methods/properties should be familiar and self-explanatory. There is always an option to directly include project's VB6 source files in your project if you don't want to ship/register extra DLL on client machines.
cheers,
</wqw>
I do not support NT 4 or 98. Google is filled with AI generated SEO hungry websites and the LibSSL3 i have does work on XP as somebody compiled it to NT 5
-
Dec 1st, 2024, 10:10 AM
#11
Thread Starter
Hyperactive Member
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by wqweto
Btw, did you try using libssl-3.dll under XP? Latest version has Subsystem Version: 6.0 flagged in PE header but XP supports up to 5.01 so this will not run on XP.
It's weird that you couldn't find VbAsyncSocket project googling for modern TLS on XP using VB6. It supports TLS 1.3 and 1.2 on NT 4.0/Win98 and later with no external dependency and includes precompiled HttpRequest.DLL which you can use as a binary reference if you insist on using DLLs in your project.
This ActiveX DLL (not Std-DLL and no Declare Functions needed) has an WinHTTP Request Object replacement class so the methods/properties should be familiar and self-explanatory. There is always an option to directly include project's VB6 source files in your project if you don't want to ship/register extra DLL on client machines.
cheers,
</wqw>
Cool, I didn't know WinHTTP was this advanced. anyways I'm gonna check it out
-
Dec 1st, 2024, 10:28 AM
#12
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by gaouser
Cool, I didn't know WinHTTP was this advanced. anyways I'm gonna check it out
You can include source code of the replacement class, not of WinHTTP Request Object. There is no source code for any of the WinHTTP.
Both the replacement class and WinHTTP support http over TLS/SSL (aka https) but the replacement class implements all of the protocol/encryption in VB6 while WinHTTP depends on OS provided Schannel library which under XP does not support modern TLS versions (like 1.3 or even latest enhancement to 1.2).
cheers,
</wqw>
Last edited by wqweto; Dec 1st, 2024 at 10:32 AM.
-
Dec 3rd, 2024, 06:02 AM
#13
Thread Starter
Hyperactive Member
Re: Any way to use libssl-3.dll in VB6?
Originally Posted by wqweto
You can include source code of the replacement class, not of WinHTTP Request Object. There is no source code for any of the WinHTTP.
Both the replacement class and WinHTTP support http over TLS/SSL (aka https) but the replacement class implements all of the protocol/encryption in VB6 while WinHTTP depends on OS provided Schannel library which under XP does not support modern TLS versions (like 1.3 or even latest enhancement to 1.2).
cheers,
</wqw>
Yeah, I know it from when I once connected to a TLS 1.3 webhook in Win7(NT6) with WinHTTP and it worked but not in XP(NT5). Thanks for the code tho.
-
Dec 3rd, 2024, 08:07 AM
#14
Re: Any way to use libssl-3.dll in VB6?
Do post a working sample using libssl-3.dll. Would be good to have a working snippet in VB6 here.
cheers,
</wqw>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|