Re: HttpWebRequest failure with TLS

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 09/23/05

  • Next message: Philipp Lenz: "Code Access Security Problems in IE-hosted Winform"
    Date: Fri, 23 Sep 2005 09:41:14 -0500
    
    

    This generally means that your client code doesn't have access to the
    private key for the certificate in question, although it could be an issue
    with certificate trust as well.

    Debugging these issues is notoriously difficult I'm afraid.

    The first thing I would do is make sure the certificate in question has a
    private key associated with it. Then, make sure you can navigate to the
    page in question with the browser and that IE will prompt you for the client
    certificate.

    After that, using regmon and filemon while the program is running is often
    very helpful for determining where Windows is looking for the private key
    file and who is getting denied access.

    There are also some kbase articles on this issue.

    Joe K.

    "Sholto Douglas" <SholtoDouglas@discussions.microsoft.com> wrote in message
    news:E9B4165D-2A81-426D-A0E1-017ABD5F8EAB@microsoft.com...
    >I am using HttpWebRequest to access a WebLogic web servce. It is currently
    > in a console app, but will be 'elevated' to a service.
    > The code is pretty standard, but I get the dreaded WebException:
    > The underlying connection was closed: Could not establish secure channel
    > for SSL/TLS
    > It uses 2-way SSL/TLS. I am adding the client certificate to the
    > ClientCertificates property. I have added the server certificate to my
    > CurrentUser store. The server has my (client) certificate. What more can
    > I
    > do, for heavens sake?
    > The WebLogic log shows that we complete the first 3 stages of the
    > handshake,
    > namely up to here:
    >
    > *** ServerHelloDone
    > HttpProcessor[8082][4], WRITE: TLSv1 Handshake, length = 4972
    > HttpProcessor[8082][4], received EOFException: error
    > HttpProcessor[8082][4], handling
    > exception:javax.net.ssl.SSLHandshakeException: Remote host closed
    > connection
    > during handshake
    > HttpProcessor[8082][4], SEND TLSv1 ALERT: fatal, description =
    > unexpected_message
    > HttpProcessor[8082][4], WRITE: TLSv1 Alert, length = 2
    > ...
    > ...
    >
    > At this point the client should send the client certificate to the server,
    > but it doesn't.
    > For what it's worth, here is the code:
    >
    > HttpWebRequest webRequest =
    > (HttpWebRequest)WebRequest.Create(sUri);
    > webRequest.Method = "POST";
    > webRequest.KeepAlive = false;
    > webRequest.ContentType = "text/xml";
    > webRequest.ContentLength = in_sXml.Length;
    > // Add the authentication certificates
    > if (m_x509ClientCert != null)
    > webRequest.ClientCertificates.Add(m_x509ClientCert);
    >
    > StreamWriter SW = new StreamWriter(webRequest.GetRequestStream());
    > SW.Write(in_sXml);
    > SW.Close();
    >
    > // Wait for response...
    > HttpWebResponse webResponse =
    > (HttpWebResponse)webRequest.GetResponse();
    >
    > It throws the exception at the webRequest.GetRequestStream() call.
    >
    > In the class constructor I have set the
    > ServicePointManager.SecurityProtocol
    > to
    > SecurityProtocolType.Tls, and the CertificatePolicy to accept all
    > certificates.
    >
    > Can anyone tell me what I have missed?
    > --
    > Thanks for any help,
    > Sholto Douglas
    > His Nerdship Pty Ltd


  • Next message: Philipp Lenz: "Code Access Security Problems in IE-hosted Winform"

    Relevant Pages

    • Re: Need for encryption in WSE 3.0 if using SS-avoid man-in-middle
      ... SSL only validates you are talking to a SSL certified server; ... They can simply edit the URL the client program ... can be done by using a X.509 certificate on both ends, ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: LDP client authentication fails
      ... I got the LDP working with LDAP server under server client authentication ... I did not installed the certificate in pfx format .. ... Client cert auth won't work without that. ...
      (microsoft.public.windows.server.active_directory)
    • Re: SSL & Man In the Middle Attack
      ... >> it possible for the middle man to intercept all messages from server to me ... > server sends client a signed message along with a digital certificate. ... > client generates a random secret key, ...
      (comp.security.misc)
    • Re: activesync issue
      ... On the SBS 2003 Server open the Server Management console. ... On the "Web Server Certificate" page, choose to create a new Web server ... Install the new certificate which created in above step on mobile device: ... Access to browse the Exchange Server 2003 client after you install ...
      (microsoft.public.windows.server.sbs)
    • problems encrypting Soap message using X.509 cert generated from makecert
      ... I have tried using both the sample certificate supplied with WSE 2.0 as ... I install the private key on the client and the public certificate on ... the private key on the server. ...
      (microsoft.public.dotnet.framework.webservices.enhancements)