经典ASP出站TLS 1.2

时间:2016-01-25 16:48:51

标签: asp.net ssl tls1.2

我们使用对USB的Web API调用来检查地址信息。他们需要TLS 1.2并且交换机已经破坏了我们的页面。

<%

If ACTION="Verify" and ncSCountry="USA" and ncSState<>"PR" and ncSState<>"AA" and ncSState<>"AP" and ncSState<>"AE" then

    Dim sXML 

    sXML = "<?xml version='1.0'?>"
    sXML = sXML & "<AccessRequest xml:lang='en-US'>"
    sXML = sXML & "<AccessLicenseNumber>XXXXXX</AccessLicenseNumber>"
    sXML = sXML & "<UserId>XXXX</UserId>"
    sXML = sXML & "<Password>XXXX</Password>"
    sXML = sXML & "</AccessRequest>"
    sXML = sXML & "<?xml version='1.0'?>"
    sXML = sXML & "<AddressValidationRequest xml:lang='en-US'>"
    sXML = sXML & "<Request>"
    sXML = sXML & "<TransactionReference>"
    sXML = sXML & "<CustomerContext /><XpciVersion>1.0001</XpciVersion>"
    sXML = sXML & "</TransactionReference>"
    sXML = sXML & "<RequestAction>XAV</RequestAction>"
    sXML = sXML & "<RequestOption>1</RequestOption></Request>"
    sXML = sXML & "<MaximumListSize>1</MaximumListSize>"
    sXML = sXML & "<AddressKeyFormat>"
    sXML = sXML & "<ConsigneeName></ConsigneeName>"
    sXML = sXML & "<BuildingName></BuildingName>"
    sXML = sXML & "<AddressLine>" & ncSAddr1   & "</AddressLine>"
    sXML = sXML & "<AddressLine>" & ncSAddr2   & "</AddressLine>"
    sXML = sXML & "<AddressLine></AddressLine>"
    sXML = sXML & "<PoliticalDivision2>" & ncSCity & "</PoliticalDivision2>"
    sXML = sXML & "<PoliticalDivision1>" & ncSState & "</PoliticalDivision1>"
    sXML = sXML & "<PostcodePrimaryLow>" &  ncSZip   & "</PostcodePrimaryLow>"
    sXML = sXML & "<CountryCode>US</CountryCode>"
    sXML = sXML & "</AddressKeyFormat>"
    sXML = sXML & "</AddressValidationRequest>"


    'Now pass the request to UPS
    Dim xmlhttp4, sResponseXML, myDoc
    Set xmlhttp4 = CreateObject("WinHttp.WinHttpRequest.5.1")
    'Set xmlhttp4 = CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp4.Open "POST","https://onlinetools.ups.com/ups.app/xml/XAV", false
    xmlhttp4.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp4.send(sXML)
    If xmlhttp4.Status >= 400 And xmlhttp4.Status <= 599 Then
        'Response.Write( "Error Occurred : " & xmlhttp.Status & " - " & xmlhttp.statusText)
        sResponseXML = "</empty>"
    Else
        sResponseXML = xmlhttp4.responseText
    End If

    Set myDoc=CreateObject("Microsoft.XMLDOM")
    myDoc.loadXML(sResponseXML)
    myDoc.async = false

    Dim addressline, addressline2, city, state, zip, zip4, responsestatus

    Dim root, NodeList, x
    Set root = myDoc.DocumentElement
    If myDoc.hasChildNodes then 
        Set NodeList = root.SelectNodes("AddressKeyFormat")
        For x = 0 To (NodeList.Length - 1)
            city = NodeList.Item(x).SelectSingleNode("PoliticalDivision2").Text
            state = NodeList.Item(x).SelectSingleNode("PoliticalDivision1").Text
            addressline = NodeList.Item(x).SelectSingleNode("AddressLine").Text

            addressline2=NodeList.Item(x).SelectSingleNode("AddressLine").NextSibling.nodename
            if addressline2="AddressLine" then
                addressline2=NodeList.Item(x).SelectSingleNode("AddressLine").NextSibling.Text
            Else
                addressline2=""
            ENd if

            zip = NodeList.Item(x).SelectSingleNode("PostcodePrimaryLow").Text
            zip4 = NodeList.Item(x).SelectSingleNode("PostcodeExtendedLow").Text
        Next
    End If

    Dim startcust3, endcust3
    startcust3=instr(sresponseXML, "<ResponseStatusCode>")
    endcust3 = instr(sresponseXML, "</ResponseStatusCode>")
    responsestatus=Mid(sResponseXML,startcust3+20,(endcust3-startcust3-20))

ENd if


%>

我已经尝试过这种切换,但我觉得我错过了一些东西。

Set xmlhttp4 = CreateObject("WinHttp.WinHttpRequest.5.1")
'Set xmlhttp4 = CreateObject("MSXML2.ServerXMLHTTP")

1 个答案:

答案 0 :(得分:13)

我找到了一个简单的注册表修复解决方案。

1)注册TLS 1.2协议:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000

2)将TLS 1.2配置为32位应用程序中的默认值:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000800

3)将TLS 1.2配置为64位应用程序中的默认值:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000800

4)重启服务器

如果您只需要支持TLS 1.1:

  • 在上面的步骤1)中,只需更改&#34; TLS 1.2&#34;到&#34; TLS 1.1&#34;并应用新的注册表修复
  • 在步骤2)和3)上面更改值&#34; 00000800&#34;至&#34; 00000200&#34;并应用新的注册表修复

如果您需要TLS 1.1和1.2的支持,那么

  • 从上面重复步骤1)两次注册两个协议
  • 在步骤2)和3)使用值&#34; 00000A00&#34; (什么是&#34; 00000800&#34; +&#34; 00000200&#34;)的组合

验证码:

<%
Set objHttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1")
objHttp.open "GET", "https://howsmyssl.com/a/check", False
objHttp.Send
Response.Write objHttp.responseText 
Set objHttp = Nothing 
%>

在回复结束时,您应该看到请求使用的TLS版本

"tls_version":"TLS 1.2"