Peregrine
Peregrine

Reputation: 4556

WebClient connecting to HTTPS gives NotFound error on some phone devices

I'm getting a NotFound error in my application when trying to download a file from a HTTPS server using WebClient. It only occurs on certain devices (eg Nokia 810), but the same application runs fine on other devices (eg Nokia 910) and also on the WP emulator. The same URL also work fine when I just enter it into a browser on the PC.

Here's a basic knock up application that demonstrates the problem.

private void Button_Click(object sender, RoutedEventArgs e)
{
    string URL = "https://MyDomain.com/MyFile.txt";
    WebClient WC = new WebClient();
    WC.DownloadStringCompleted += WC_DownloadStringCompleted;
    WC.DownloadStringAsync(new Uri(URL));
}

void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    if (e.Error == null)
        txtResult.Text = e.Result;
    else
        txtResult.Text = "ERROR:\r\n" + e.Error.Message + "\r\n" + e.Error.StackTrace;
 }

Unfortunately the server is out of my control, but it does have a full certificate (signed by Thawte) so it's not an issue with self signed certificates.

I've tried this test app both as WP7.1 and WP8 and it fails consistently on the same devices.

This is an app for public consumption so installing the certificate on the phone or any other phone configuration setting is not an option.

Upvotes: 2

Views: 314

Answers (1)

Peregrine
Peregrine

Reputation: 4556

I've managed to solve this issue, but the solution was not directly an issue with the code.

Some of our beloved testers were advancing the date by a year on the device in order to test changes to application account status, and not resetting back to the correct date. This of course led to the device flagging the certificate with an expiry date of Feb 2014 as invalid and thus failing the HTTPS calls.

Upvotes: 1

Related Questions