Results 1 to 31 of 31

Thread: VB6 with TLS 1.2 support

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    538

    VB6 with TLS 1.2 support

    i have been using the following code to query an API services.

    Code:
        Dim objHTTP As Object
        Dim Result As String
        Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
        objHTTP.Open "GET", URL, False
        objHTTP.send
        Result = objHTTP.responseText
        Set objHTTP = Nothing
    However , using https just started to fail. Looks like i was using TLS 1.0 by default.
    Now the site have set TLS 1.1 as minimum. So i did latest updates for Win7 Pro 64 Bit
    Still did not work. After a bit of hunting around, i found a change was needed.

    Code:
    Dim objHTTP As Object
    Dim Result As String
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    objHTTP.open "GET", URL, False
    objHTTP.send
    Result = objHTTP.responseText
    Set objHTTP = Nothing
    this now works fine.

    Just wanted to know if there is a better or faster solution with less overheads.

    many thanks
    Last edited by k_zeon; Mar 18th, 2019 at 03:53 PM.

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    ServerXMLHTTP is a small wrapper within a large library, that wraps WinHttp. Why not just use WinHttp instead of loading both libraries into your program's address space?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    538

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by dilettante View Post
    ServerXMLHTTP is a small wrapper within a large library, that wraps WinHttp. Why not just use WinHttp instead of loading both libraries into your program's address space?
    Hi dilettante. I did try but it did not work. It errors out on If .waitForResponse(3) Then.

    Please can you give a working example. thank you.

    Code:
    '    Dim HTTPRequest As WinHttp.WinHttpRequest
    '
    '    Set HTTPRequest = New WinHttp.WinHttpRequest
    '    With HTTPRequest
    '        .open "GET", URL, True
    '        .Option(WinHttpRequestOption_SecureProtocols) = SecureProtocol_ALL
    '        .Option(WinHttpRequestOption_EnableRedirects) = True
    '        .send
    '        If .waitForResponse(3) Then
    '            MsgBox .responseText
    '        Else
    '            MsgBox "Timed out after 3 seconds."
    '        End If
    '    End With
    '    Set HTTPRequest = Nothing

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    That just means 3 seconds wasn't enough. What happens when you just do a synchronous request, since that's what you seem to want to do anyway?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    538

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by dilettante View Post
    That just means 3 seconds wasn't enough. What happens when you just do a synchronous request, since that's what you seem to want to do anyway?
    i tried:-

    Code:
        Dim HTTPRequest As WinHttp.WinHttpRequest
        Set HTTPRequest = New WinHttp.WinHttpRequest
        With HTTPRequest
            .open "GET",URL, False 
            .Option(WinHttpRequestOption_SecureProtocols) = SecureProtocol_ALL
            .Option(WinHttpRequestOption_EnableRedirects) = True
            .send
            MsgBox .responseText
        End With
        Set HTTPRequest = Nothing
    but it errors out with a runtime error ' a connection to the server could not be established'

    It seems that the minimum TLS on the website for TheMovieDB is now 1.1 to 1.2 (recently changed) and i think that the above code is still trying to use 1.0
    not sure on that though. Any thoughts.

    as i said , below works fine passing the url

    Code:
    Dim objHTTP As Object
    Dim Result As String
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    objHTTP.open "GET", URL, False
    objHTTP.send
    Result = objHTTP.responseText
    Set objHTTP = Nothing

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    Are you using a supported version of Windows? You may not have recent SSL/TLS support.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    This code is working:

    Code:
    Option Explicit
    '
    'Reference to: Microsoft WinHTTP Services, version 5.1
    '
    
    Private Sub Main()
        Dim HTTPRequest As WinHttp.WinHttpRequest
    
        Set HTTPRequest = New WinHttp.WinHttpRequest
        With HTTPRequest
            .Open "GET", "http://www.google.com/", True
            .Option(WinHttpRequestOption_SecureProtocols) = SecureProtocol_ALL
            .Option(WinHttpRequestOption_EnableRedirects) = True
            .Send
            If .WaitForResponse(3) Then
                MsgBox .ResponseText
            Else
                MsgBox "Timed out after 3 seconds."
            End If
        End With
        Set HTTPRequest = Nothing
    End Sub

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    For Win7 SP1 you might need:

    Update to enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows

    For Windows 10 you need to be at 1507 or later I believe. See:

    TLS Cipher Suites in Windows 10 v1507

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    538

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by dilettante View Post
    For Win7 SP1 you might need:

    Update to enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows

    For Windows 10 you need to be at 1507 or later I believe. See:

    TLS Cipher Suites in Windows 10 v1507
    I did update before i checked above code. I even made sure the registry had the correct info.

    your code below does work for google, but if i put a moviedb url it does not. Could it be that MovieDB have not configured their site correctly as the TLS recently was udated to min 1.1.?

    if i use "https://api.themoviedb.org/3/search/tv?api_key=<<key>>&language=en-US&query=bones&page=1" as the url it fails.
    if i change to http then it works fine.

    Code:
    Private Sub Main()
        Dim HTTPRequest As WinHttp.WinHttpRequest
    
        Set HTTPRequest = New WinHttp.WinHttpRequest
        With HTTPRequest
            .Open "GET", "http://www.google.com/", True
            .Option(WinHttpRequestOption_SecureProtocols) = SecureProtocol_ALL
            .Option(WinHttpRequestOption_EnableRedirects) = True
            .Send
            If .WaitForResponse(3) Then
                MsgBox .ResponseText
            Else
                MsgBox "Timed out after 3 seconds."
            End If
        End With
        Set HTTPRequest = Nothing
    End Sub

  10. #10
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    Sorry, I'm out of ideas. Maybe somebody else can help?

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    538

    Re: VB6 with TLS 1.2 support

    ok, tks

  12. #12
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    706

    Re: VB6 with TLS 1.2 support

    Google is still using an old protocol to allow older mobile phones to connect. Not every secure website is using the new protocol yet.

  13. #13
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    706

    Re: VB6 with TLS 1.2 support

    Searching the web for "VB6 wininet TLS 1.2" and clicking on the first link resulted in a solution, but it requires OS update and adding a registry entry.

  14. #14
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    Maybe try with SecureProtocol_TLS1_2 (instead of SecureProtocol_ALL).

    I tried some testing sites and they frowned when SecureProtocol_ALL was used because the older insecure ciphers are permitted.

  15. #15
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    706

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by dilettante View Post
    Maybe try with SecureProtocol_TLS1_2 (instead of SecureProtocol_ALL).

    I tried some testing sites and they frowned when SecureProtocol_ALL was used because the older insecure ciphers are permitted.
    I tried that on Windows 7 with all updates, and without adding the registry entry, and got "Invalid Procedure Call or Argument" on the options line.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2011
    Posts
    538

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by qvb6 View Post
    I tried that on Windows 7 with all updates, and without adding the registry entry, and got "Invalid Procedure Call or Argument" on the options line.
    me too. got an error using SecureProtocol_TLS1_2

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

    Re: VB6 with TLS 1.2 support

    On Win10 accessing https://api.themoviedb.org w/ SecureProtocol_ALL I get An error occurred in the secure channel support.

    With SecureProtocol_TLS1_2 the handshake is established ok and even result is passed back: {"status_code":7,"status_message":"Invalid API key: You must be granted a valid key.","success":false}

    cheers,
    </wqw>

  18. #18
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,664

    Re: VB6 with TLS 1.2 support

    Enable this reg key: Software\Microsoft\Windows\CurrentVersion\Internet Settings, "SecureProtocols", "2688"

    This would enabled the TLS1.2 + SSL options in the IE Settings.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  19. #19
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    We aren't talking about IE though, or WinInet/UrlMon at all. This is a separate HTTP stack from IE's.

  20. #20
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,492

    Re: VB6 with TLS 1.2 support

    I don't know if this has anything to do with your issue, but I will pass it on anyway. The latest version of TLS is 1.3. If and when a web server implements TLS 1.3, there were some minor changes implemented to TLS 1.2. One of those changes is that it is only allowed to fall back one version level. This is accomplished by adding a specific text string to the Server Random if a lower version is requested.

    J.A. Coutts

  21. #21
    Member
    Join Date
    Apr 2009
    Posts
    48

    Re: VB6 with TLS 1.2 support

    I've run into the same problem. I need VB6 to connect via HTTPS and the code works for google, but nothing else...

  22. #22
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 with TLS 1.2 support

    This works on Windows 10 1903:

    Code:
    Option Explicit
    
    Private Sub Main()
        Dim HTTPRequest As WinHttp.WinHttpRequest
    
        Set HTTPRequest = New WinHttp.WinHttpRequest
        With HTTPRequest
            .Open "GET", "https://stackoverflow.com/", True
            .Option(WinHttpRequestOption_SecureProtocols) = SecureProtocol_ALL
            .Send
            If .WaitForResponse(3) Then
                MsgBox .ResponseText
            Else
                .Abort
                MsgBox "Timed out after 3 seconds."
            End If
        End With
        Set HTTPRequest = Nothing
    End Sub

  23. #23
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: VB6 with TLS 1.2 support

    Hi,

    I wish to resurrect this old thread, to clear this for me up.

    I'm developing on Windows 7 64-bit SP1 with all recent official patches found on MS Catalog website, and I also did all from:
    Update to enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows
    How to enable TLS 1.2 on clients
    Configure secure protocol options for WinHTTP

    Also applied windows6.1-kb3140245-x64.msu and MicrosoftEasyFix51044.msi as mentioned, but without any luck.

    Now, I'm using code like always before, "Not Referenced in the project", just creating the Objects on the fly, like these:

    Code:
    Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    and

    Code:
    Set objHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    This issue started about a month ago, before I could use "https://" without any issue, and now I'm getting errors, only the pure "http://" works.

    But, I noticed something on my website license structure (see attached screenshots):

    Attachment 191473

    Attachment 191474

    Is there any solution for this "quick fix" on Windows 7 64-bit platform? (Did MS revoked the licenses or it's just outdated from the site TLS 1.3 version?)

    Or I need to move to Windows 10, 11 (I don't know which one is the worsts OS I ever seen in my life).

    Thank you for your help!
    Last edited by beic; May 6th, 2024 at 06:11 AM. Reason: typo

  24. #24

  25. #25
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by wqweto View Post
    Is it possible your site does not support TLS 1.2 already but started requiring 1.3 at some point in time?
    Ohh, I just noticed that, they went straight to TLS 1.3, without leaving 1.0 and 1.1 compatibility support...

  26. #26
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by beic View Post
    Ohh, I just noticed that, they went straight to TLS 1.3, without leaving 1.0 and 1.1 compatibility support...
    I found out, that in the cPanel you can change the TLS Encryption type, I can go down to 1.2, but unfortunately support for 1.0 and 1.1 was revoked.

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

    Re: VB6 with TLS 1.2 support

    TLS 1.0 is released in 1999 and TLS 1.1 in 2006 but both are deprecated since 2021 which means there are known vulnerabilities which are never going to be fixed already.

    Frankly we have landing pages which support SSL3 so that IE6 on XP w/ no Service Pack opens these but this is not very safe.

    cheers,
    </wqw>

  28. #28
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: VB6 with TLS 1.2 support

    So, the "best" option is to limit running compiled EXE on older Windows (if you wish to use "https" TLS 1.2 and above).

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

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by beic View Post
    So, the "best" option is to limit running compiled EXE on older Windows (if you wish to use "https" TLS 1.2 and above).
    The best option is to just use a cHttpRequest instance from Http Request Replacement Ax-DLL project instead and enjoy both TLS 1.3 and TLS 1.2 connections on every Windows down to NT4 but this obviously is my biased opinion.

    cheers,
    </wqw>

  30. #30
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: VB6 with TLS 1.2 support

    Quote Originally Posted by wqweto View Post
    The best option is to just use a cHttpRequest instance from Http Request Replacement Ax-DLL project instead and enjoy both TLS 1.3 and TLS 1.2 connections on every Windows down to NT4 but this obviously is my biased opinion.

    cheers,
    </wqw>
    Would like to try it, but I can't find example for simple parameters, like: .Open, .Send, .Status, .ResponseText, etc... or is it 100% compatible with "WinHTTP.WinHTTPRequest.5.1"?

    Thanks for your answer!

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

    Re: VB6 with TLS 1.2 support

    In repo's README it has a section about the "WinHttpRequest Replacement Class":

    > Notice that the original Open method and Option property of the WinHttpRequest object have been suffixed with an
    > underscore (_) in the replacement implementation (a limitation of the VB6 IDE) so some source-code fixes will be
    > required to integrate the replacement cHttpRequest class.

    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
  •  



Click Here to Expand Forum to Full Width