1

这是我的代码

Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"

'.net 4.0
ServicePointManager.SecurityProtocol = DirectCast(3072, SecurityProtocolType)

Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String = Encoding.ASCII.GetString(Param)
strRequest = strRequest + "&cmd=_notify-validate"
req.ContentLength = strRequest.Length

Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)

这是我得到的错误(第 47 行是上面代码中的最后一个)

Exception type: WebException 
Exception message: The underlying connection was closed: An unexpected error occurred on a receive.
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at ProcessIPN.Page_Load(Object sender, EventArgs e) in ProcessIPN.aspx.vb:line 47
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The client and server cannot communicate, because they do not possess a common algorithm
at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)
at System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage, SecureCredential& secureCredential)
at System.Net.Security.SecureChannel.AcquireClientCredentials(Byte[]& thumbPrint)
at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)
at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)

我在服务器上安装了 .net 4.5,并且正在使用 VB(我知道)我尝试过使用我在此处找到的 .net 4.5 的另一个 SecurityProtocol 字符串,但这也不起作用我已经翻译了上面的 4.0 一个C# 但不确定它是否正确。我应该说这在没有 ServicePointManager 行的情况下在 2015 年 12 月运行良好这是我尝试过的 .net 4.5 行

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 
4

0 回答 0