Why wouldn't I be able to establish a trust relationship for a SSL/TLS channel?
- by Abe Miessler
I have a piece of .NET code that is erroring out when it makes a call to HTTPWebRequest.GetRequestStream. Here is the error message:
The underlying connection was closed:
Could not establish trust relationship
for the SSL/TLS secure channel.
I've read a few things that suggest that I might need a certificate on the machine running the code, but i'm not sure if that's true or how to do it.
If I need to get a certificate, how do I do it?
Code:
var request = (HttpWebRequest)HttpWebRequest.Create(requestUrl); //my url
request.Method = StringUtilities.ConvertToString(httpMethod); // Set the http method GET, POST, etc.
if (postData != null)
{
request.ContentLength = postData.Length;
request.ContentType = contentType;
using (var dataStream = request.GetRequestStream())
{
dataStream.Write(postData, 0, postData.Length);
}
}