我已经安装了 paypal api 证书并使用 winhttpcertcfg 授予私钥访问正确身份的权限。我已经用尽了在各种论坛上找到的所有“已知修复程序”,但仍然出现此错误。我正在运行最新的 msxml 版本。
使用 Paypal 代码示例我得到错误
msxml3.dll error '80072f0c' A certificate is required to complete client authentication
无论是使用 MSXML2.ServerXMLHTTP 的 3.0、4.0 还是 6.0 版本,错误都是不变的,并且在尝试使用 REST Api 时收到相同的错误。
我正在测试连接的代码如下。
<%
Dim vrequest, strPayPalCert
Dim payPalURL, payPalUser, payPalAppID, payPalPassword, payPalClientID, payPalSecret
Const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056
Const SXH_OPTION_SELECT_CLIENT_SSL_CERT = 3
payPalURL = "https://api.sandbox.paypal.com"
payPalUser = "xx_user_xx"
payPalAppID = "APP-80W284485P519543T"
payPalPassword = "xx_password_xx"
payPalClientID = "xx_client_id_xx"
payPalSecret = "xx_secret_xx"
Const paypal_request_format = "JSON"
Const paypal_response_format = "JSON"
strPayPalCert = "paypal_cert_name"
vrequest = vrequest & "&actionType=" & "PAY"
vrequest = vrequest & "&cancelUrl= cancelUrl.asp"
vrequest = vrequest & "&clientDetails.ipAddress=" & Request.ServerVariables("LOCAL_ADDR")
vrequest = vrequest & "&clientDetails.partnerName=MySite"
vrequest = vrequest & "¤cyCode=USD"
vrequest = vrequest & "&feesPayer=0.00"
vrequest = vrequest & "&receiverList.receiver(0).email=receiver@paypal.com"
vrequest = vrequest & "&receiverList.receiver(0).amount=1.00"
vrequest = vrequest & "&requestEnvelope.errorLanguage=" & "en_US"
vrequest = vrequest & "&requestEnvelope.detailLevel=" & "ReturnAll"
vrequest = vrequest & "&returnUrl=returnURL.asp"
If not isobject(vXMLHttp) Then
Set vXMLHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
End If
vXMLHttp.setOption(2) = SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
' This throws certificate error due to space
vXMLHttp.setOption(3) = "LOCAL_MACHINE\My\ " & strPayPalCert
'This works
vXMLHttp.setOption(3) = "LOCAL_MACHINE\My\" & strPayPalCert
strURL = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"
vXMLHttp.open "POST", strURL, false
vXMLHttp.setRequestHeader "X-PAYPAL-SECURITY-USERID", payPalUser
vXMLHttp.setRequestHeader "X-PAYPAL-SECURITY-PASSWORD", payPalPassword
vXMLHttp.setRequestHeader "X-PAYPAL-REQUEST-DATA-FORMAT", paypal_request_format
vXMLHttp.setRequestHeader "X-PAYPAL-RESPONSE-DATA-FORMAT", paypal_response_format
vXMLHttp.setRequestHeader "X-PAYPAL-APPLICATION-ID", payPalAppID
vXMLHttp.Send vrequest
vXMLHttp.waitForResponse 5
strResponse = vXMLHttp.responseText
Set RegularExpressionObject = nothing
Set vXMLHttp = nothing
arrList = split(strResponse, chr(38))
For each item in arrList
Response.Write(item & "<br />" )
Next
strTemp = arrList(4)
arrList = split(strTemp, chr(61))
Response.Write("<br><br>Now you need to redirect user to paypal server to complete transaction using following URL:<br>")
Response.Write("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" &arrList(1))
%>
编辑以显示解决方案
请您参考如下方法:
证书身份验证在经典 ASP 中不起作用。尝试使用外部库(如 cURL)来执行 HTTPS 请求。