3
Public Sub GetAPIToken(aUserName As String, aPassword As String, aResponse As String)

    Dim WinHttpReq As Object

    Dim strURL As String, strJSON As String

    Set WinHttpReq = CreateObject("MSXML2.ServerXMLHTTP")

    strURL = "https://example.com/v1/users/login"

    strJSON = "{" _

                & Chr(34) & "username" & Chr(34) & ":" & Chr(34) & aUserName & Chr(34) & "," _

                & Chr(34) & "password" & Chr(34) & ":" & Chr(34) & aPassword & Chr(34) _

            & "}"
              
    With WinHttpReq

       .Open "POST", strURL, False

       .setRequestHeader "Content-Type", "application/json"

       .Send strJSON   **>> error on this line**

       aResponse = .responseText

    End With

    Set WinHttpReq = Nothing

End Sub

Error: -2147012739 (80072f7d) : An error occurred in the secure channel support

above code working fine on Windows 10 pc but this error came on Windows 7 pc

eglease
  • 2,445
  • 11
  • 18
  • 28
  • Is UTC on the Windows 7 machine disabled? Are you running the .exe as admin? – eglease Oct 25 '21 at 14:54
  • I'd try disabling UAC but same error, i'm running this code through VB6 development panel (while debugeing) – Prashant Bahire Oct 26 '21 at 05:46
  • 1
    Has this Windows 7 machine [TLS1.2 installed and activated](https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392)? – Hel O'Ween Oct 26 '21 at 10:17
  • I found that, Remote machine where this API hosted had TLS1.3 security that's why Windows 7 facing problem. Is there any way to solve this issue? In Firefox this API runs perfectly (i think they had TLS1.3 support) – Prashant Bahire Oct 27 '21 at 06:05
  • [Win 7 doesn't seem to support TLS1.3 natively](https://sockettools.com/kb/windows-and-supported-tls-versions/). So besides you implementing it yourself or using a 3rd party library, you're out of luck there, I'm afraid. – Hel O'Ween Oct 27 '21 at 08:17
  • You can try [WinHttpRequest Replacement Class](https://github.com/wqweto/VbAsyncSocket/blob/master/contrib/cHttpRequest.cls) with XP/Win7 compatible TLS 1.3 support in pure VB6 (works on NT4/2000 too) for a source-compatible drop-in replacement of both stock `ServerXMLHTTP`/`XMLHTTP` and `WinHttpRequest` http request objects. Check out repo's README for usage and installation. – wqw Nov 09 '21 at 17:43

0 Answers0