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?
If the 3rd party webservice is secured using a self signed certificate, you will need to install their CA signing certificate into your trusted certificates keystore
EDIT based on code sample.
I’ve tried an example calling those facebook urls without problem doing an http get to one of the graph.facebook urls without error using the code sample below. Please can you update your example with what you’re trying to post and to which URL?
At the moment from what I can see from mine, it seems to work, so can only assume a certificate problem on the pc your’re executing it from still.