Re: Could not establish secure channel for SSL/TLS.



Icky. I hate troubleshooting client cert stuff.

Did you try this tool to see if it helps?

http://www.microsoft.com/downloads/details.aspx?FamilyID=cabea1d0-5a10-41bc-83d4-06c814265282&displaylang=en

Looking in the system event log for errors from schannel can sometimes yield
helpful results.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"mikem" <mikemarano@xxxxxxxxx> wrote in message
news:1170946580.160468.145380@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am trying to make web service calls via HttpWebRequest to a secure
server that requires a client certificate. The server appears to be a
Sun-ONE-Web-Server/6.1 and I am told that they are using a Nortel SSL
accelerator. The client is an ASP.NET application running on IIS6 /
windows 2003. I am using the HttpWebRequest class to make the
connection. I have followed all the directions I could find on MSDN,
etc. I have downloaded the winhttpcertcfg.exe tool, exported the
client certificate as a DER encoded .cer file (the client certificate
is also used as a server certificate to encrypt traffic in IIS6, and
is located in the LOCAL_MACHINE/My store). and ensured that the
Network Service account / ASPNET account / even Everyone has access to
the private key (as a test). I have also set the app pool to run as
the local system account but I still get this error. The error
message - inner exception - stack trace is :

The underlying connection was closed: Could not establish secure
channel for SSL/TLS. - System.ComponentModel.Win32Exception: The token
supplied to the function is invalid - at
System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult
asyncResult) at System.Net.HttpWebRequest.GetRequestStream() at
G1SBS.AkoTest.sendRequest()

I was able to successfully establish a connection and make a web
service request using a win32 build of the unix CURL command. So I
know that the server is up and running and that the client certificate
is good. I am at a total loss as to why this is happening - Please
help. I can provide more info should you need. Here is the code I am
using the send the request:

System.Net.ServicePointManager.CertificatePolicy = new
TrustAllCertificatePolicy();
System.Net.ServicePointManager.Expect100Continue = false;

XmlDocument x = new XmlDocument();
x.InnerXml = "<REQUEST>request</REQUEST>";

string targetUrl = "https://targeturl/test.do";
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(targetUrl);

// add client certificate to request
X509Certificate clientCert = X509Certificate.CreateFromCertFile("C:\
\client.cer");
req.ClientCertificates.Clear();
req.ClientCertificates.Add(clientCert);

req.Method="POST";
req.ContentType="text/xml";
req.KeepAlive = false;
//req.MaximumAutomaticRedirections = 40;
//req.AllowWriteStreamBuffering = false;
//req.ProtocolVersion = HttpVersion.Version10;

byte [] reqBytes = UTF8Encoding.UTF8.GetBytes(x.InnerXml);
req.ContentLength = reqBytes.Length;
req.Timeout = 120000;

Stream postData = req.GetRequestStream(); ** ERROR ON THIS LINE **
postData.Write(reqBytes,0,reqBytes.Length);
postData.Close();

HttpWebResponse res = (HttpWebResponse) req.GetResponse();
StreamReader resStream = new StreamReader(res.GetResponseStream(),
UTF8Encoding.UTF8);
string sR = resStream.ReadToEnd();
res.Close();
resStream.Close();

return sR;



.



Relevant Pages

  • Re: HttpWebRequest
    ... I paste below both client and server side. ... string FileName = HttpUtility.UrlDecode; ... I use a HttpWebRequest object to download a file. ...
    (microsoft.public.dotnet.framework)
  • problem with ssls client authentication
    ... I am using Windows 2000 Server with IIS 5.0 and I have activated SSL ... and client authentication on my IIS server. ... I have installed client certificate in my browser from both CA i use. ... When I put on the CTL control with the certificate of IDX-PKI root CA, ...
    (microsoft.public.inetserver.iis.security)
  • Re: Responding to a HttpWebRequest
    ... I have an ASP.NET application (client) thats uses HttpWebRequest ... > However, on the server side, what classes do I need to use to get the ... > incoming post data and then return a response code? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: [opensuse] Postfix not recognising me (WAS: Postfix does not seem to be logging)
    ... John wrote: ... working but the server does not allow me to relay mail from my phone to ... If you are trying to use client certs, ... log where the client is presenting a client certificate. ...
    (SuSE)
  • Re: Error SEC_E_ALGORITHM_MISMATCH from InitializeSecurityContext
    ... the server does support TLS1 (the version field in server Hello is ... Is it possible that the client certificate has some problems (don't ask me ... InitializeSecurityContext (that uses it to generate the TLS record with the ...
    (microsoft.public.platformsdk.security)