微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

HttpWebRequest不起作用:接收时发生意外错误

如何解决HttpWebRequest不起作用:接收时发生意外错误

TLS是TLS 1.3,Linux服务器。
密码:TLS_AES_256_GCM_SHA384
错误:接收时发生意外错误 '''

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.DefaultConnectionLimit = 9999;
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)12288;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://example.com/oauth/token?grant_type=password&username=aptk0012&password=9875322");
            request.Method = "POST";
            request.ContentType = "application/json";
            string post_data = "Basic VV9mZ.....";
            request.Headers.Add("Authorization",post_data);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string result = reader.ReadToEnd();

''' 但是邮递员做到了。

在这里帮助我!

完整的错误详细信息在这里

'''See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog Box.

************** Exception Text **************
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.ComponentModel.Win32Exception: 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 count)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming,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,Object state)
   at System.Net.Tlsstream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.Tlsstream.Write(Byte[] buffer,Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer,Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at WindowsFormsApplication1.Form1.ND_Get_Token(String username,String password,LabelControl lbMessage,Boolean is_show_msg) in C:\Users\orgil\OneDrive\Documents\Visual Studio 2015\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 512
   at WindowsFormsApplication1.Form1.btGetEMDToken_Click(Object sender,EventArgs e) in C:\Users\orgil\OneDrive\Documents\Visual Studio 2015\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 488

'''

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。