none
HttpClient on iOS/Android to on-prem SharePoint RRS feed

  • Question

  • I've tried this in PCL (.NET Core 1.1)/Xamarin (Visual Studio 2015) and .NET Standard 2.0/Xamarin (Visual Studio 2017). I've tried with and without modernhttpclient.

    We have on premises SharePoints that I want to query from .NET in UWP, Android and iOS. All three devices are able to be on our network. Our network is based on Active Directory. In UWP, I can connect just fine - using NetworkCredential(userid, password, domain); In both Android and iOS app deployments, I get exceptions about a certificate.

    This is essentially what I'm doing. At the point where I wrote "EXCEPTION", during debug I see a five-level deep exception stack that terminates with "Invalid certificate received from server. Error code: 0xffffffff800b010b"

    private string loginPostURL = "https://mycorporatesharepoint";

    var cookies = new CookieContainer(); FormUrlEncodedContent wsoD = null;

    handler = new HttpClientHandler(); // AndroidClientHandler() handler.Credentials = new NetworkCredential(userId, password, domain); handler.UseCookies = true; handler.CookieContainer = cookies; handler.ClientCertificateOptions = ClientCertificateOption.Automatic;

    var client = new HttpClient(handler); var response = client.PostAsync(loginPostURL, wsoD).Result; ---> EXCEPTION in iOS and Android if (response.StatusCode == HttpStatusCode.OK) { Cookies = cookies.GetCookies(new Uri(loginPostURL)).Cast<Cookie>().ToList(); IsAuthenticated = true; }

    I really have no idea what certificate it is complaining about. This post from Steve Liles show he had a similar problem. He diagnosed it with openssl, but I'm not allowed to run openssl in my company. Liles' conclusion is that the backend is mis-configured. If that is true with our SharePoints, I don't know enough to tell the administrators what to do.

    However, why does it work in UWP? Furthermore, the iOS and Android (or Samsung) browsers on the devices can log into the SharePoints after filling in the same username/password on the challenge forms. Shouldn't HttpClient behave the same??


    john


    Wednesday, November 1, 2017 4:48 PM

All replies