Results 1 to 14 of 14

Thread: Any way to use libssl-3.dll in VB6?

  1. #1

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    World:\Turkey\User32.DLL
    Posts
    441

    Red face 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!
    I'M GAOUSEEEERRRRRRR

    Experimental Software and stuff made by me with some being efforts of up to 3 months of endless VB6 IDE

    VBForums is made with VBulletin4, Fun Fact their first 2 letters are same.

    Gaouser is a weird name choice
    I love VB6 and NX 8.5 and CorelDRAW and C++ and HTML4.01 and obsolote stuff and retrocomputing!
    I custom ROM my phones
    Using Win32 API is easier in VB6 than VB.NET

  2. #2
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    870

    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.

  3. #3

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    World:\Turkey\User32.DLL
    Posts
    441

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by qvb6 View Post
    If your goal is to connect to HTTPS sites, try the sample here:

    https://www.vbforums.com/showthread....=1#post5661169

    OpenSSL is poorly documented.
    Agreed, OpenSSL isn't even documented for Windows version at all. thanks for the link.
    I'M GAOUSEEEERRRRRRR

    Experimental Software and stuff made by me with some being efforts of up to 3 months of endless VB6 IDE

    VBForums is made with VBulletin4, Fun Fact their first 2 letters are same.

    Gaouser is a weird name choice
    I love VB6 and NX 8.5 and CorelDRAW and C++ and HTML4.01 and obsolote stuff and retrocomputing!
    I custom ROM my phones
    Using Win32 API is easier in VB6 than VB.NET

  4. #4

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    World:\Turkey\User32.DLL
    Posts
    441

    Re: Any way to use libssl-3.dll in VB6?

    I will return back upon testing that ActiveX.
    I'M GAOUSEEEERRRRRRR

    Experimental Software and stuff made by me with some being efforts of up to 3 months of endless VB6 IDE

    VBForums is made with VBulletin4, Fun Fact their first 2 letters are same.

    Gaouser is a weird name choice
    I love VB6 and NX 8.5 and CorelDRAW and C++ and HTML4.01 and obsolote stuff and retrocomputing!
    I custom ROM my phones
    Using Win32 API is easier in VB6 than VB.NET

  5. #5
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    870

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by gaouser View Post
    I will return back upon testing that ActiveX.
    It's part of Windows, so nothing to deploy, and it's easy to use.

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,477

    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?

  7. #7
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,170

    Re: Any way to use libssl-3.dll in VB6?

    libcurl has fairly easy to use high level wrappers around it for https traffic

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,477

    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.

  9. #9
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,583

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by gaouser View Post
    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>

  10. #10

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    World:\Turkey\User32.DLL
    Posts
    441

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by wqweto View Post
    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
    I'M GAOUSEEEERRRRRRR

    Experimental Software and stuff made by me with some being efforts of up to 3 months of endless VB6 IDE

    VBForums is made with VBulletin4, Fun Fact their first 2 letters are same.

    Gaouser is a weird name choice
    I love VB6 and NX 8.5 and CorelDRAW and C++ and HTML4.01 and obsolote stuff and retrocomputing!
    I custom ROM my phones
    Using Win32 API is easier in VB6 than VB.NET

  11. #11

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    World:\Turkey\User32.DLL
    Posts
    441

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by wqweto View Post
    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
    I'M GAOUSEEEERRRRRRR

    Experimental Software and stuff made by me with some being efforts of up to 3 months of endless VB6 IDE

    VBForums is made with VBulletin4, Fun Fact their first 2 letters are same.

    Gaouser is a weird name choice
    I love VB6 and NX 8.5 and CorelDRAW and C++ and HTML4.01 and obsolote stuff and retrocomputing!
    I custom ROM my phones
    Using Win32 API is easier in VB6 than VB.NET

  12. #12
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,583

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by gaouser View Post
    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>

  13. #13

    Thread Starter
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    World:\Turkey\User32.DLL
    Posts
    441

    Re: Any way to use libssl-3.dll in VB6?

    Quote Originally Posted by wqweto View Post
    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.
    I'M GAOUSEEEERRRRRRR

    Experimental Software and stuff made by me with some being efforts of up to 3 months of endless VB6 IDE

    VBForums is made with VBulletin4, Fun Fact their first 2 letters are same.

    Gaouser is a weird name choice
    I love VB6 and NX 8.5 and CorelDRAW and C++ and HTML4.01 and obsolote stuff and retrocomputing!
    I custom ROM my phones
    Using Win32 API is easier in VB6 than VB.NET

  14. #14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width