Re: Underlying Connection Was Closed Error



Hi WeluR,

Yeah, Microsoft Network Monitor 3.1, works fine even on Vista )
http://www.microsoft.com/downloads/details.aspx?familyid=18b1d59d-f4d8-4213-8d17-2f6dde7d7aac&displaylang=en


Regards, Alex
[TechBlog] http://devkids.blogspot.com



I have a web client application built on .Net Frameworks 2.0 that
connects to
a web service on IIS 6.0 via SSL and using X509 Client Certificates.
At some
locations (it works at others), I get the following error. Below is
my code.
I've also used System.Net.Tracing and have the traffic generated as a
result
of the web request if anyone wants to view it.
System.Net.WebException: There was an error downloading
'https://web-site-url/web-service.asmx'. ---> System.Net.WebException:
The
underlying connection was closed: An unexpected error occurred on a
send.
---> System.IO.IOException: The handshake failed due to an unexpected
packet
format.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32
readBytes, AsyncProtocolRequest asyncRequest)
... remainder ommitted for brevity.

THE CODE:

' Connect to Web Service
Dim metwebProxy As New CalAuthWs
Dim userProxy As IWebProxy
' Set certificate policy to ignore metweb certificate error
notifications ServicePointManager.ServerCertificateValidationCallback
= g_certificateValidationCallback

metwebProxy.PreAuthenticate = True

' Set Network Proxy Server depending on user selections
If String.Compare(My.Settings.UserProxy, m_PROXY_DEFAULT, True) = 0
Then
....userProxy = WebRequest.DefaultWebProxy
....If Not userProxy Is Nothing Then
........If My.Settings.UseDefaultCredentials Then
............userProxy.Credentials = CredentialCache.DefaultCredentials
........End If
........metwebProxy.Proxy = userProxy
....End If
ElseIf String.Compare(My.Settings.UserProxy, m_PROXY_USER_DEFINED,
True) = 0
Then
....' User has manual proxy server settings
....userProxy = Utilities.GetUserProxyServer
....If Not userProxy Is Nothing Then metwebProxy.Proxy = userProxy
End If
' Add client-side certificate
metwebProxy.ClientCertificates.Add(x509In)
' Test Connection
If metwebProxy.TestLogin(certificateSubject, ApplicationSource.AFCAV)
Then
....Return metwebProxy
Else
....' Web Service indicates system is down
....Dim status As String = metwebProxy.ServerStatus
....DisplayMessage(True, "Access Denied: WebAFCAV is currently not
available. Status: " & status)
....Return Nothing
End If


.



Relevant Pages

  • Re: Underlying Connection Was Closed Error
    ... a web service on IIS 6.0 via SSL and using X509 Client Certificates. ... or the .NET Framework Networking and Communication forum at http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=40&SiteID=1. ...
    (microsoft.public.dotnet.framework.webservices)
  • web services over http
    ... I have a webservice setup for which I want to use client certificates. ... installed a client-certificate for my web browser.My web browser can now connect to the web service, and the web service recieves the client ... System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream) +1130 ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • WebService on https
    ... I have a webservice setup for which I want to use client certificates. ... installed a client-certificate for my web browser.My web browser can now connect to the web service, and the web service recieves the client ... System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream) +1130 ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Calling SSL enabled web service
    ... I have a web service that works fine without SSL and trying to enable SSL and ... require client certificates. ... I am currently receiving a 403: ...
    (microsoft.public.dotnet.framework.webservices)

Loading