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 believe I have all the require certificates...
This is how I checked to see if I had the required certificates:
- hit the webservice using Firefox.
- Look at the certificates being used to hit that web service by looking at the security info through the browser
- export the certificates
- import the certificates through Internet Options in the control panel
Should this be sufficient? I am still getting the error.
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);
}
}
UPDATE:
Adding some screen shots of my certs. Let me know if anything looks wrong:
First, we have the cert that Firefox is using:
Next, we have what is in my Trusted Root Certs according to the MMC:
Last, we have what is in my Intermediate certs according to the MMC:
Does this look right?