本文介绍了WinHTTP.WinHTT prequest.5.1不TLS 1.2后,贝宝沙箱工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

贝宝沙箱刚刚仅限于TLS 1.2连接。这使得我们的网站停止与贝宝沙箱工作,尽管它与剧照生产的PayPal工作。在未来生产PayPal将有相同的限制。我们使用贝宝的沟通传统的ASP和微软WinHTTP.WinHTT prequest.5.1组件。下面是低于code。 objHttp.StatusText返回错误的请求。我们在Windows Server 2008 R2上。我试图用MSXML2.ServerXMLHTTP.6.0代替,但它只能在我的Windows 8.1开发计算机上,而不是我们的Windows Server 2008 R2上。虽然MSXML2.ServerXMLHTTP.6.0是WinHTTP.WinHTT prequest.5.1的超集,但它比WinHTTP.WinHTT prequest.5.1不太可靠。我们code未能在过去使用MSXML2.ServerXMLHTTP.6.0每天几次,所以我用WinHTTP.WinHTT prequest.5.1 preFER。我也是在这行code的不自信:objHttp.Option(9)=&安培; H0AA0。我们使用呼吁发送消息到贝宝的WebAPI一种解决方法;然而,这会导致额外的小的延迟。

 暗淡objHttp
设置objHttp =的Server.CreateObject(WinHTTP.WinHTT prequest.5.1)
朦胧WinHtt prequestOption_EnableHttp1_1:WinHtt prequestOption_EnableHttp1_1 = 17
objHttp.Option(WinHtt prequestOption_EnableHttp1_1)= FALSE朦胧WinHtt prequestOption_SslErrorIgnoreFlags:WinHtt prequestOption_SslErrorIgnoreFlags = 4
objHttp.Option(WinHtt prequestOption_SslErrorIgnoreFlags)=安培; H3300
objHttp.setTimeouts 0,120000,120000,120000
objHttp.Option(9)=&放大器; H0AA0'2720
objHttp.open后,&放大器; https://api-3t.sandbox.paypal.com/2.0/与& 假
strRequest = SETEX pressCheckoutSOAP(RETURNURL,cancelURL)
objHttp.setRequestHeader内容类型,文本/ XML的,字符集= UTF-8
objHttp.setRequestHeader的Content-Length,LEN(strRequest)objHttp.setRequestHeader主机,api-3t.sandbox.paypal.com
呼叫objHttp.send(strRequest)
如果objHttp.Status = 200则
   RESP = objHttp.responseText
其他
   回复于objHttp.StatusText
万一

的WebAPI调用code:

 暗淡webapiresp,webapidata
webapidata ={网址:,&放大器; gv_APIEndpoint&安培; ,消息,:,与& nvpStrComplete&安培; ,,肥皂:0}
webapiresp = InvokeWebAPI(strApiDomain,POST,通信/发送,,webapidata)
        集回复= JSON.parse(webapiresp)
        RESP = reply.xml功能InvokeWebAPI(strApiDomain,方法,funcname的,参数,数据)
昏暗的Htt preQ,apiURI,RESP设置的Htt preQ =的Server.CreateObject(MSXML2.ServerXMLHTTP)
apiURI = strApiDomain&安培; funcname的&安培;参数
apiURI = strApiDomain&安培; API /&放大器; funcname的&安培;参数
HTT preq.open方法,apiURI,假HTT preq.setRequestHeader内容类型,应用/ JSON的;字符集= UTF-8
HTT preq.setRequestHeaderSOAPAction报,apiURI
HTT preq.setRequestHeader授权,基本&放大器; Base64En code(XXX:XXX)如果数据<> 然后
    HTT preq.send数据
其他
    HTT preq.send
万一RESP = Htt的preq.responseText设置的Htt preQ =什么InvokeWebAPI = RESP
结束功能


解决方案

我的应用程序是用ASP经典,我用 WinHttp.WinHtt prequest.5.1 中地方 MSXML2.ServerXMLHTTP.6.0 的。张贴到贝宝沙箱网址。

什么工作对我说的是 WinHttp.WinHtt prequest.5.1 objec 使用TLS 1.2:

设置

  HTT prequest =的Server.CreateObject(WinHttp.WinHtt prequest.5.1)
HTT prequest.option(9)= 2720

所有的在Windows Server 2012上的

PayPal sandbox just recently restricted to TLS 1.2 connection. This makes our site stop working with PayPal sandbox although it stills work with the production PayPal. In the future the production PayPal will have the same restriction. We're using classic ASP and Microsoft WinHTTP.WinHTTPRequest.5.1 component for communication with PayPal. Here's the code below. objHttp.StatusText returns "Bad Request". We're on Windows Server 2008 R2. I tried to use MSXML2.ServerXMLHTTP.6.0 instead, but it only works on my Windows 8.1 development machine, not on our Windows Server 2008 R2. Although MSXML2.ServerXMLHTTP.6.0 is a superset of WinHTTP.WinHTTPRequest.5.1, but it is less reliable than WinHTTP.WinHTTPRequest.5.1. Our code fails a few times a day using MSXML2.ServerXMLHTTP.6.0 in the past, so I prefer using WinHTTP.WinHTTPRequest.5.1. I'm also not confident in this line of code: objHttp.Option(9) = &H0AA0 . A workaround that we're using is calling the WebAPI for sending message to PayPal; however, this causes an extra minor delay.

dim objHttp
Set objHttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1")
dim WinHttpRequestOption_EnableHttp1_1 : WinHttpRequestOption_EnableHttp1_1 = 17
objHttp.Option(WinHttpRequestOption_EnableHttp1_1) = False

dim WinHttpRequestOption_SslErrorIgnoreFlags : WinHttpRequestOption_SslErrorIgnoreFlags=4
objHttp.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300
objHttp.setTimeouts 0, 120000, 120000, 120000
objHttp.Option(9) = &H0AA0 '2720
objHttp.open "post", "" & "https://api-3t.sandbox.paypal.com/2.0/" & "", False
strRequest = SetExpressCheckoutSOAP(returnURL, cancelURL)
objHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objHttp.setRequestHeader "Content-Length", Len(strRequest)

objHttp.setRequestHeader "Host", "api-3t.sandbox.paypal.com"
Call objHttp.send(strRequest)
if objHttp.Status = 200 then
   resp = objHttp.responseText
else
   response.write objHttp.StatusText
end if

WebAPI invoke code:

dim webapiresp, webapidata
webapidata = "{""url"":""" & gv_APIEndpoint & """, ""message"":""" & nvpStrComplete & """,""soap"":0}"
webapiresp=InvokeWebAPI(strApiDomain, "POST", "comm/send", "", webapidata)
        set reply=JSON.parse(webapiresp)
        resp = reply.xml

Function InvokeWebAPI(strApiDomain, method, funcname, param, data)
dim HttpReq, apiURI, resp

set HttpReq=Server.CreateObject("MSXML2.ServerXMLHTTP")
'apiURI=strApiDomain & funcname & param
apiURI=strApiDomain & "api/" & funcname & param


HttpReq.open method, apiURI, false

HttpReq.setRequestHeader "Content-Type", "application/json; charset=UTF-8"
HttpReq.setRequestHeader "SOAPAction", apiURI
HttpReq.setRequestHeader "Authorization", "Basic " & Base64Encode("xxx:xxx")

if data <> "" then
    HttpReq.send data
else
    HttpReq.send
end if

resp = HttpReq.responseText

set HttpReq=Nothing

InvokeWebAPI = resp
End Function
解决方案

My application is written in ASP classic and I use WinHttp.WinHttpRequest.5.1in place of MSXML2.ServerXMLHTTP.6.0. to post to paypal sandbox url.

What works for me is telling the WinHttp.WinHttpRequest.5.1 objec to use TLS 1.2:

Set

httpRequest = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
httpRequest.option (9) = 2720

All that on Windows Server 2012

这篇关于WinHTTP.WinHTT prequest.5.1不TLS 1.2后,贝宝沙箱工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 11:24