OK, I have managed to get a little further. I decided to go an
alternate route and use OpenSSL to create the certificate according to
another set of instructions with the custom HTTP server. The result is
a DER encoded X509 certificate which the server is now using on the
HTTPS port. I know this because if I view the servers HTML page using
HTTPS Firefox and IE throw a fit because the Certificate is not
recognised. I can then Import the Certificate into my personal store.
When running the C# code for the HTTPWebRequest if I cycle through the
certificates using the following it is there and can be added as
follows
X509Store store = new X509Store(StoreName.My,
StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
foreach (X509Certificate cert in store.Certificates)
{
webRequest.ClientCertificates.Add(cert); // this finds the
certificate (validated by examining the certs in here in Debug)
}
Stream requestStream = webRequest.GetRequestStream(); <---
EXCEPTION THROWN HERE
requestStream.Write(reqBytes, 0, reqBytes.Length);
I get the following Exception when attempting to GetRequestStream()
[System.Net.WebExceptionStatus.TrustFailure'
"The underlying connection was closed: Could not establish trust
relationship for the SSL/TLS secure channel."
"The remote certificate is invalid according to the validation
procedure"
So my question is... I have the certificate in my Personal store, I
can see it in C#. IE can connect to the site happily now that I have
installed the cert. So WHY am I getting this failure in the Trust
Relationship ?
Any thoughts
Al