I'm trying to determine why a call to a Restful API endpoint is failing when I use HTTPS but not HTTP from a Windows Server 2012 R2. The same HTTPS call works when I run the application locally on my laptop (Windows 7).
Unfortunately I cannot get Fiddler to show the calls made from the application on the Web Server to the API. The AppContainer Loopback Exemption Utility errors trying to enumerate the AppContainers list. The Server is also locked down by group policies, so I can't turnoff the firewall to try to resolve the Fiddler issue.
The call to the API is:
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request)
{
client = new HttpClient();
// removed code for setting ignoreCertErrors and environmentName
if (ignoreCertErrors && environmentName.ToUpper() != "PROD")
{
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
}
return client.SendAsync(request);
}
Errors received:
================================================================= Message: The underlying connection was closed: An unexpected error occurred on a send. Stack Trace:
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResultar)================================================================= Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. Stack Trace:
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)================================================================= Message: An existing connection was forcibly closed by the remote host Stack Trace:
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)=================================================================
How can obtain more detail? I'm trying to avoid low level tools such as Wireshark, I'm hoping there is option trace/log/capture more detail about the application calls to API that are failing.
UPDATE - Here is the tracing information when it fails:
System.Net Information: 0 : [2292] SecureChannel#49584532::.ctor(hostname=XX.XX.com, clientCertificates=0, encryptionPolicy=RequireEncryption)
System.Net Information: 0 : [2292] SecureChannel#49584532 - Left with 0 client certificates to choose from.
System.Net Information: 0 : [2292] Using the cached credential handle. System.Net Information: 0 : [2292] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = XX.XX.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation) System.Net Information: 0 : [2292] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=178, returned code=ContinueNeeded).
System.Net.Sockets Verbose: 0 : [2292] Socket#14347911::BeginSend()
System.Net.Sockets Verbose: 0 : [2292] Exiting Socket#14347911::BeginSend() -> OverlappedAsyncResult#19699911 System.Net.Sockets Verbose: 0 : [2292] Data from Socket#14347911::PostCompletion
[ Removed ]
System.Net.Sockets Verbose: 0 : [2292] Socket#14347911::EndSend(OverlappedAsyncResult#19699911)
System.Net.Sockets Verbose: 0 : [2292] Exiting Socket#14347911::EndSend() -> Int32#178
System.Net.Sockets Verbose: 0 : [2292] Socket#14347911::BeginReceive()
System.Net.Sockets Verbose: 0 : [2292] Exiting Socket#14347911::BeginReceive() -> OverlappedAsyncResult#2389992
System.Net.Sockets Verbose: 0 : [2292] Socket#14347911::EndReceive(OverlappedAsyncResult#2389992)
System.Net.Sockets Error: 0 : [2292] Socket#14347911::UpdateStatusAfterSocketError() - ConnectionReset
System.Net.Sockets Error: 0 : [2292] Exception in Socket#14347911::EndReceive - An existing connection was forcibly closed by the remote host. System.Net.Sockets Verbose: 0 : [2292] Exiting Socket#14347911::EndReceive() -> Int32#0
System.Net.Sockets Verbose: 0 : [2292] Socket#14