Silverlight 4 OOB + Browser HTTP Stack + Client Certificates = FAIL?

4

I'm having an issue where IIS 7.5 (on Windows 7 64-bit) is failing when I call it from an out-of-browser Silverlight 4 app using SSL and a client certificate, with the message "The I/O operation has been aborted because of either a thread exit or an application request. (0x800703e3)". The request does make it to IIS. here is a sample from the failed request trace:

The I/O operation has been aborted because of either a thread exit or an application request. (0x800703e3) http://www.slipjig.org/IISError.gif

I am using the browser HTTP stack, because the client HTTP stack does not support client certificates. The client code attempting to hit the server is the Prism module loader. If I run the app out-of-browser but ignore client certs, or if I run the application in-browser but require client certs, it works fine. It seems to be the combination of the two that is causing the problem.

I tried the following to gather more info:

  • Used Fiddler to view the failing request. It works if Fiddler is running (presumably because Fiddler is handling the client certificate differently?);
  • Created an .aspx web form to serve up the module .xaps;
  • Created an HTTPModule to see if I could intercept the request before it failed;
  • Used a packet sniffer to see if I could tell if the client certificate was being sent correctly.

None of the above gave me much useful information beyond what I could see in the trace file, although the Fiddler thing is interesting.

Any ideas? Thanks in advance! Mike

silverlight
iis
certificate
out-of-browser
asked on Stack Overflow Jul 8, 2010 by slipjig • edited Nov 19, 2015 by pnuts

3 Answers

4

I beat my head against the wall for weeks on this problem. Here's what I learned and how I finally worked around it.

Prism's FileDownloader class uses System.Net.WebClient to load modules. In OOB mode, WebClient seems to use the same stack as IE, but it apparently either doesn't send the client certificate, or (more likely) doesn't correctly negotiate the SSL/client cert handshake with the server. I say this because:

  • I was able to successfully request .xap files using Firefox and Chrome;
  • I was not able to successfully request .xap files using IE;
  • IIS would fail with a 500, not a 403.

I couldn't get good visibility into what was actually happening over the wire; if I used Fiddler, it would work, because Fiddler intercepts communications with the server and handles the client certificate handshake itself. And trying to use a packet sniffer obviously wouldn't tell me anything because of SSL.

So - I first spent a lot of time on the server side trying to eliminate things (unneeded handlers, modules, features, etc.) that might be causing the problem.

When that didn't work, I tried modifying the Prism source code to use the browser's HTTP stack instead of WebClient. To do this, I created a new class similar in design to FileDownloader, implementing IFileDownloader, that used the browser stack. I then made some changes to XapModuleTypeLoader (which instantiates the downloader) to make it use the new class. This approach failed with the same error I was originally experiencing.

Then I started researching whether a commercial third-party HTTP stack might be available. I found one that supported the features I needed and that supported the Silverlight 4 runtime. I created another implementation of IFileDownloader that used that stack, and BOOM - it worked.

The good news with this approach is that not only can I use this to load modules, I can also use it to protect communications between the client and our REST API (a benefit we were going to give up, before).

I plan to submit a patch to Prism to allow the downloader to be registered or bound externally, as it's currently hard-coded to use its own FileDownloader. If anyone is interested in that or in the commercial HTTP stack I'm using, contact me (msimpson -at- abelsolutions -dot- com) for links and code samples.

And I must say this - I still don't know for sure whether the root problem is in the HTTP stack on the client side or the server side, but it's a FAIL on Microsoft's part nonetheless.

answered on Stack Overflow Aug 14, 2010 by slipjig • edited Aug 14, 2010 by slipjig
0

What we (Slipjig and I) found out this week is that there does appear to be a way around these issues, or at least, we're on the trail to determining whether there is a reliable, repeatable way. We're still not positive on that, but here's what we know so far:

At first pass, if you have code like this you can start making requests with either the Browser or Client stack:

First, place a "WebBrowser" control in your Silverlight XAML, and make it send a request to your HTTPS site.

This may pop up the certificate dialog box for the user. Big deal. Accept it. If you have only one cert, then you can turn an option in IE off to suppress that message.

private void Command_Click(object sender, RoutedEventArgs e) {
  // This does not pop up the cert dialog if the option to take the first is turned on in IE settings:
  BrowserInstance.Navigate(new Uri("https://www.SiteThatRequiresClientCertificates.com/"));
}

Then, in a separate handler invoke by the user, create an instance of your stack, either Client or Browser:

private void CallServer_Click(object sender, RoutedEventArgs e) {
           // Works with BrowserHttp factory also:
            var req = WebRequestCreator.ClientHttp.Create(new Uri("https://www.SiteThatRequiresClientCertificates.com/"));
            req.Method = "GET";
            req.BeginGetResponse(new AsyncCallback(Callback), req);
}

Finally, the Callback:

private void Callback(IAsyncResult result)
{
            var req = result.AsyncState as System.Net.WebRequest;
            var resp = req.EndGetResponse(result);
            var content = string.Empty;
            using (var reader = new StreamReader(resp.GetResponseStream())) {
                content = reader.ReadToEnd();
            }
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                Results.Text = content;
            });
}
answered on Stack Overflow Dec 8, 2010 by JoshGough
0

I had the same issue and I fixed it by creating the certificate using makecert. Follow the steps from this article http://www.codeproject.com/Articles/24027/SSL-with-Self-hosted-WCF-Service and replace CN with your ip/domain. In my case I have tested the service on the local machine and run the commands as follows:

1) makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a sha1 -n "CN=Dev Certification Authority" -ss my -sr localmachine

after running the first command drag the certificate from "Personal" directory to "Trusted Root Certification Authority"

2) makecert -iv SignRoot.pvk -ic signroot.cer -cy end -pe -n CN="localhost" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12

In case you want to run the silverlight application on another machine, export the certificate created at step1 and then import it on any machine where you want your application to run.

answered on Stack Overflow Aug 13, 2012 by alex

User contributions licensed under CC BY-SA 3.0