本文介绍了底层连接已关闭。无法为ssl / tls安全建立信任关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

我在网络服务器上托管网站时收到以下错误。





基础连接已关闭。无法为ssl / tls安全通道建立信任关系。

我附上了您的推荐代码。请给我这个问题的解决方案。





公共字符串posted_data()

{

string urls =http://www.mydomain.com?uname=hi&password=123;

ASCIIEncoding encoding = new ASCIIEncoding();

流newStream;

string postData =;

postData + =(urls);





byte [] data = encoding.GetBytes(urls);



//准备网页请求...

HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create(urls);



myRequest.Method =POST;

myRequest.Accept = text / plain;

myRequest.ContentType =application / x-www-form-urlencoded;

myRequest.ContentLength = data.Length;

newStream = myRequest.GetRequestStream();

//发送数据。



newStream.Write(da ta,0,data.Length);

//抓住回复

HttpWebResponse HttpWResp =(HttpWebResponse)myRequest.GetResponse();

Stream streamResponse = HttpWResp.GetResponseStream();



//并将其读出来

StreamReader reader = new StreamReader(streamResponse);

string response = reader.ReadToEnd();

newStream.Close();

返回响应;

}

Hi sir,
I am getting the below error, while hosting the website in webserver.


"the underlying connection was closed. could not establish trust relationship for the ssl/tls secure channel".
I attached the code for your refernce. Kindly give me the solution for this problem.


public string posted_data()
{
string urls="http://www.mydomain.com?uname=hi&password=123";
ASCIIEncoding encoding = new ASCIIEncoding();
Stream newStream;
string postData = "";
postData += (urls);


byte[] data = encoding.GetBytes(urls);

// Prepare web request...
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(urls);

myRequest.Method = "POST";
myRequest.Accept = "text/plain";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
newStream = myRequest.GetRequestStream();
// Send the data.

newStream.Write(data, 0, data.Length);
// grab the response
HttpWebResponse HttpWResp = (HttpWebResponse)myRequest.GetResponse();
Stream streamResponse = HttpWResp.GetResponseStream();

// And read it out
StreamReader reader = new StreamReader(streamResponse);
string response = reader.ReadToEnd();
newStream.Close();
return response;
}

推荐答案


这篇关于底层连接已关闭。无法为ssl / tls安全建立信任关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:41