Open CerealGuy93 opened 4 years ago
Is this the same issue that has affected Xamarin.Android? Android issue: https://developercommunity.visualstudio.com/content/problem/756697/last-visual-studio-update-brakes-ntlm-authenticati.html
@dfoulk No, the issue that impacts android boils down to the native library that socketshttphandler depends on is not supported on android.
It looks like this bug has made it to the release version Visual Studio 16.5.0 and Xamarin.iOS and Xamarin.Mac SDK 13.14.1.39 that was just released a few days ago.
Is there a known work around for this?
Seems like the bug made it into VS 16.5. @BlakeMartin838 no, there is no fix other than using the older VS to create ios
Thanks @CerealGuy93 I've been waiting since September for them to fix a similar issue with Android and the same update that fixes Android, this bug comes and affects iOS. Do you know if this has been logged on https://developercommunity.visualstudio.com/ ?
@BlakeMartin838 @CerealGuy93 Can you try using a .net core sample and see if that works? iOS is using SocketsHttpHandler
.... A forked version of it, but should be pretty close to the same with respect to the ntlm parts.
With android, the "fix" was to just enable the old mono handler, which we could also do w/ iOS should this be a hard problem to solve. I doubt that, since iOS was functional from our testing.
This particular Xamarin application that I am having these issues with is calling custom web services on SharePoint, so I am unable to convert these web services to .net core. I can start rewriting this application to not use SharePoint and use .net core instead if this is the direction of the Xamarin. Is this how I should be thinking about these issues?
@steveisok i tried it with a .net core application against the same API and the requests are working.
@CerealGuy93 Thanks. What is your server setup?
@CerealGuy93 @steveisok , are we talking .net core on the Xamarin side or the server/web service side?
@BlakeMartin838 I meant to try using a simple .net core client application and see if you're able to authenticate against whatever you have protected.
@steveisok I am currently working against a mvc api behind an iss with a trusted link on a separate AD server. I hope that's the infos you need
@steveisok Is there anything else you need in order to implement a fix for this for Xamarian.iOS like you did for Xamarin.Android?
@BlakeMartin838 The android issue was (eventually) clear cut as libgss
isn't supported there. It's something we're trying to hash out for .net 5.
For ios, we're more or less sharing the same code as .net core and accessing the same library, so I'd like to try and investigate it a bit more. That's why seeing if a .net core client sample (on the mac) works is important. And your server setup as well so that I can try to recreate the same conditions.
@steveisok We had to roll back from VS 2019 to VS 2017 because of the mono issue. Apple is telling us we wont be able to push our ipa's to the store come April because they aren't on Xamarin.IOS 13 SDK. We can't get on Xamarin.IOS 13 because we need VS 2019. We can't get on VS2019 because of this bug. What can we do?
Here's the initial workaround we suggested for android: https://github.com/EgorBo/NtlmHttpHandler
You could try to adapt that for ios for now. Not sure what would be needed as of yet.
Or, if you dont know how to make this work here is my workaround: Open your solution with VS16.4.X, connect your Mac and install the "Xamarin.iOS SDK 13.10.0.17" Close this Visual Studio and open the current Version 16.5.X, connect your Mac and abort the "Xamarin.iOS SDK"-Update.
In my case everything is working again, i wont publish my app with this "workaround" but i can develop my app.
@CerealGuy93 Can you have VS 16.4.X and VS 16.5.X installed on the same machine or are you doing this on two different machines?
@BlakeMartin838 you can have multiple installations of VS. If you have multiple version you can overview them in your visual studio installer. Just fyi (i didnt know this a few weeks back) you can even install multiple "sub-version" at the same time. If you need a specific 16.4.x version you can find them here "https://docs.microsoft.com/en-us/visualstudio/releases/2019/history".
hope this helps
We've now had issues with NTLM authentication in Xamarin.Forms since October of 2019. Please prioritize this issue.
@steveisok i think i missunderstood your first request (the sample application in .net Core), i checked the code on Windows with .net core, not on a MAC.
Today i tested this code on both platforms: `private static readonly string RequestUrl = "url"; private static readonly string Username = "usr"; private static readonly string Password = "abc";
static async Task Main(string[] args)
{
var handler = new HttpClientHandler();
if (handler.SupportsAutomaticDecompression)
handler.AutomaticDecompression = DecompressionMethods.GZip;
handler.Credentials = new NetworkCredential(Username, Password);
var client = new HttpClient(handler, true);
var result = await client.GetAsync(RequestUrl);
Console.WriteLine(result.IsSuccessStatusCode ? "Success" : $"Failed with Code {result.StatusCode}; Reason: {result.ReasonPhrase};");
}`
Its working on Windows 1903 (18362.720), but with macOS Catalina (10.15.3) its returning unauthorized. I installed the latest .net core 3.1.201 on both devices.
Does anyone have a development environment that still works with Xamarian iOS and NTLM Authentication that I can try to get working on my side? I had VS 16.4.5 and Xamarin.iOS 13.10.0.17 working until last week when the Apple update broke the connection between my PC and Mac (https://developercommunity.visualstudio.com/content/problem/961788/broker-error.html?childToView=971226#comment-971226). Now I can connect to debug on the simulator but when I try to compile a production release I get "dsymutil exited with code 1"
@CerealGuy93 It would be helpful if you could file an issue in the dotnet runtime repo. Since it fails on .net core too, they own that feature and probably would have a better idea what to do.
Describing your server setup in detail will also be important to help us set the same conditions.
@BlakeMartin838 We have an environment that works currently with Visual Studio 16.3 and .NET Core 3.1. If I were you, I would try installing Visual Studio 16.3 as a second VS2019 install. You may need to roll XCode back to the appropriate version for that version of VS as well. I know- "that is ridiculous", but it's what we have right now- I suppose...
BT dubs: We're using NtlmHttpHandler to repair the NTLM client on Android that broke before this did. 😑
#### About Microsoft Visual Studio ``` Microsoft Visual Studio Enterprise 2019 (2) Version 16.3.1 VisualStudio.16.Release/16.3.1+29324.140 Microsoft .NET Framework Version 4.8.03752 Installed Version: Enterprise Architecture Diagrams and Analysis Tools 00435-60000-00000-AA181 Microsoft Architecture Diagrams and Analysis Tools Visual C++ 2019 00435-60000-00000-AA181 Microsoft Visual C++ 2019 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools Application Insights Tools for Visual Studio Package 9.1.00913.1 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2019 16.3.283.64955 ASP.NET and Web Tools 2019 ASP.NET Web Frameworks and Tools 2019 16.3.283.64955 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.3.283.64955 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.3.9000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.3.283.64955 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.3.9000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Dotfuscator Community Edition 5.42.0.9514-e0e25f754 PreEmptive Protection - Dotfuscator CE Extensibility Message Bus 1.2.0 (d16-2@8b56e20) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events GitHub.VisualStudio 2.10.8.8132 A Visual Studio Extension that brings the GitHub Flow into Visual Studio. IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info JetBrains ReSharper Ultimate 2020.1 EAP 5 Build 201.0.20200313.144645-eap05 JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2020 JetBrains, Inc. Microsoft Azure HDInsight Azure Node 2.3.9000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.3.9000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.3.9000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.20816.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.0.83+gbc8a4b23ec Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.3.7 (9d260c5) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 5.3.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ PowerShell Pro Tools for Visual Studio 1.0 A set of tools for developing and debugging PowerShell scripts and modules in Visual Studio. ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.61908.27190 Microsoft SQL Server Data Tools SQL Server Reporting Services 15.0.1659.0 Microsoft SQL Server Reporting Services Designers Version 15.0.1659.0 SQLite & SQL Server Compact Toolbox 4.7 SQLite & SQL Server Compact Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections. ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.10821.2002 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 10.4 for F# 4.6 16.3.0-beta.19455.1+0422ff293bb2cc722fe5021b85ef50378a9af823 Microsoft Visual F# Tools 10.4 for F# 4.6 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.3.0.274 (d16-3@06531f8) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.3.0.230 (remotes/origin/d16-3-xcode11@bbe518670) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.3.565 (27e9746) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 10.0.0.43 (d16-3/8af1ca8) Xamarin.Android Reference Assemblies and MSBuild support. Mono: mono/mono/2019-06@7af64d1ebe9 Java.Interop: xamarin/java.interop/d16-3@5836f58 LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333 Xamarin.iOS and Xamarin.Mac SDK 13.2.0.42 (5e8a208) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```
@NWhittle Are iOS builds on your machine still performing NTLM authentication successfully? If so, can you post your environment info here, please?
I've got the first workaround integrated into my Forms app(s) and I am able to authenticate on iOS via NTLM without issues. Note that the particular workaround I am using is not the latest suggestion by MS for this issue. Their latest 'fix' as per this thread is to set that MSBuild property that supposedly rolls the Mono HTTP Client back to a legacy version.
Seeing as I can authenticate on my iOS apps through the original workaround linked above, you may want to avoid rolling the mono client back via the MSBuild property as is suggested by MS and instead use the original workaround which you can see actually only makes changes when on the Android environment:
Type androidenvType = Type.GetType("Android.Runtime.AndroidEnvironment, Mono.Android");
if (androidenvType == null)
{
// For non-Android systems the default HttpClientHandler works fine with NTLM via GSS
// e.g. GSS.frameworks for macOS and iOS and krb5 on Linux (requires `gss-ntlmssp` package installed)
return new HttpClientHandler();
}
Other than matching my approach using that workaround, I also included my build environment below so you can compare our development environments to eliminate differences and try to narrow things down.
``` Microsoft Visual Studio Enterprise 2019 Version 16.4.6 VisualStudio.16.Release/16.4.6+29905.134 Microsoft .NET Framework Version 4.8.03752 Installed Version: Enterprise Visual C++ 2019 00435-60000-00000-AA591 Microsoft Visual C++ 2019 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASP.NET and Web Tools 2019 16.4.462.24200 ASP.NET and Web Tools 2019 ASP.NET Web Frameworks and Tools 2019 16.4.462.24200 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.4.462.24200 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.4.1000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.4.462.24200 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.4.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 3.4.1-beta4-20120-08+fa984e0202af4480c0273032da49cbbdeb32c582 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 16.4.19310.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format. Extensibility Message Bus 1.2.0 (d16-2@8b56e20) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info JetBrains ReSharper Ultimate 2019.3.4 Build 193.0.20200226.112949 JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2020 JetBrains, Inc. Microsoft Azure HDInsight Azure Node 2.4.1000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.4.1000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.4.1000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21016.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.0.87+gbb515bf382 Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.5.24 (1fafd7e) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.5.11023.1 Commit Hash:579896f0984848d17d080c8a1c3ddff98d5ba96f Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 5.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Open in Sublime Text 1.1.30 Adds a menu command that lets you open any solution, project, folder and file in Sublime Text. ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Python 16.4.19310.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python - Conda support 16.4.19310.1 Conda support for Python projects. Python - Django support 16.4.19310.1 Provides templates and integration for the Django web framework. Python - IronPython support 16.4.19310.1 Provides templates and integration for IronPython-based projects. Python - Profiling support 16.4.19310.1 Profiling support for Python projects. Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.62002.03150 Microsoft SQL Server Data Tools ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.11031.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.4.1-beta4-20120-08+fa984e0202af4480c0273032da49cbbdeb32c582 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 10.4 for F# 4.6 16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354 Microsoft Visual F# Tools 10.4 for F# 4.6 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.4.000.313 (d16-4@793df40) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.4.0.475 (remotes/origin/d16-4@ac250f5aa) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.4.25 (579ee62) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 10.1.4.0 (d16-4/e44d1ae) Xamarin.Android Reference Assemblies and MSBuild support. Mono: fd9f379 Java.Interop: xamarin/java.interop/d16-4@c4e569f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b Xamarin.iOS and Xamarin.Mac SDK 13.10.0.21 (02c4b3b) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```
Best of luck! Let me know if there's anything I can do to help.
My current workaround is a modified version of EgorBos NtlmHttpHandlerFactory. I dont know if this has any downsides or is release ready but its working for me and i can develop until there is a real workaround.
My version:
public static HttpClientHandler Create()
{
var monoHandlerType = Type.GetType("System.Net.Http.MonoWebRequestHandler, System.Net.Http");
if (monoHandlerType == null)
throw new InvalidOperationException("System.Net.Http.MonoWebRequestHandler was not found in System.Net.Http." + LinkerTipText);
var internalMonoHandlerCtors = monoHandlerType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (internalMonoHandlerCtors.Length < 1)
throw new InvalidOperationException("Internal parameter-less constructor for System.Net.Http.MonoWebRequestHandler was not found." + LinkerTipText);
var httpClientHandlerCtors = typeof(HttpClientHandler).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance);
if (httpClientHandlerCtors.Length < 1)
throw new InvalidOperationException("internal HttpClientHandler(IMonoHttpClientHandler) constructor was not found in System.Net.Http.HttpClientHandler." + LinkerTipText);
var internalMonoHandler = internalMonoHandlerCtors[0].Invoke(null);
return (HttpClientHandler)httpClientHandlerCtors[0].Invoke(new[] { internalMonoHandler });
}
I removed the Android check and added "BindingFlags.Public" to the "GetConstructors" call.
Hope this helps someone and hopefully doesnt break anything.
We decided to update our Visual Studio to the latest stable (16.5.4) and began running into the same issues as @CerealGuy93 did with our existing usage of the same workaround factory.
We tried the PropertyGroup fix as has been recently added to Visual Studio as instructed by MS in this thread and the Android issue went away but it broke iOS authentication with 401 status responses coming back just like @CerealGuy93 reported.
We decided to implement the original workaround with some tweaks as @CerealGuy93 did and the 401 issues went away (as well as the Android issues as the original workaround was applying correctly now). Note that our working configuration does not include the PropertyGroup workaround.
Thank you for sharing your approach @CerealGuy93!
@NWhittle hopefully we will see NTLM working properly again in the near future. It sounds like the recommended workarounds are not working in a Xamarin.Forms solution.
@steveisok Do you know if anybody is working on fixing this so that we can eliminate these workarounds and get things back to normal?
@dfoulk The problem w/ iOS does seem like an issue w/ osx in general on .net core. My recommendation was to create an issue there, but since that hasn't happened, then perhaps I could log one.
As for android, that is a tougher problem and probably will be addressed in .net 5.
@NWhittle im glad that the solution works for you. We just published our app with the workaround and so far no reported problems.
@steveisok you are right, i totally forgot about the issue for dotnet core. Have your already created a issue or should i still do it?
AFAIK the NSUrlSessionHandler will correctly deal with NTLM, which is the recommended one on iOS. This is a netcore/mono issue. @steveisok if we have a netcore issue, I would mention it here and would close this one.
I can confirm that NTLM works with Xamarin.iOS SDK 13.10.0.17 but it is broken with every release after.
I testet it in the client project im currently working on.
Any news on this matter? Updated my test machine and have the same NLTM issues on iOS
Can confirm the given workaround with the modified version of EgorBos NtlmHttpHandlerFactory above works in my Xamarin Forms app but this should be fixed for the standard NSUrlSessionHandler!
Is this still an open issue? I am using an older version of Visual Studio and have turned off all updates for Xcode for iOS and the latest version of Visual Studio for Android.
Is this still an open issue? I am using an older version of Visual Studio and have turned off all updates for Xcode for iOS and the latest version of Visual Studio for Android.
Yes, this is still an issue. No idea if someone is fixing this!?
We're impacted by this as well. The workaround is not that simple for us because we use a custom handler that inherits from the default one... is there anyone working on this?
CerealGuy93's static handler works for US....THANK YOU FOR PROVIDING THIS WORKAROUND.
So when is this issue going to be fixed for real...IT HAS BEEN OCCURRING SINCE JANUARY!!!
@bburtonpa I think we are S.O.L. until (at the earliest) November 2020, when .NET 5 is released.
For those that are following this thread, IF you are communicating with a Rest service hosted on IIS with Windows Authentication enabled, changing your code to authenticate using BASIC authentication will work. NO changes to IIS will be required other that to enable BASIC authentication. As for the web service, in our case, no changes at all were required to the code.
Example:
using(HttpClientHandler httpHandler = new HttpClientHandler())
{
var authData = $"{username}:{password}";
var authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData));
using(HttpClient httpClient = new HttpClient() { Timeout = new TimeSpan(0, 0, 0, timeout) })
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
using(HttpResponseMessage response = httpClient.GetAsync(requestUri).GetAwaiter().GetResult())
{
using(var stream = response.Content.ReadAsStreamAsync().GetAwaiter().GetResult())
{
using(var reader = new StreamReader(stream))
{
string text = reader.ReadToEnd();
// do something with the result
}
}
}
}
}
NOTE: you MAY need to add the domain name to the username:
var authData = $"{username}@mydomain.com:{password}";
Hope that helps...
I was able to confirm that @bburtonpa method works but is using Basic Authentication in an app over HTTPS secure?
@BlakeMartin838
TL;DR It may be considered "secure" because the HTTPS request is encrypted, but it is not the recommended authentication scheme. NTLM is more secure. Granted, I wouldn't consider either schemes secure if you're not protecting the user's credentials on the client device.
Quote from 2014 Microsoft:
Because the credentials are sent unencrypted, Basic authentication is only secure over HTTPS
Source: https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/basic-authentication
A summary of the two authentication methods:
Basic Basic authentication sends a Base64-encoded string that contains a user name and password for the client. Base64 is not a form of encryption and should be considered the same as sending the user name and password in clear text. If a resource needs to be protected, strongly consider using an authentication scheme other than basic authentication.
NTLM NT LAN Manager (NTLM) authentication is a challenge-response scheme that is a securer variation of Digest authentication. NTLM uses Windows credentials to transform the challenge data instead of the unencoded user name and password. NTLM authentication requires multiple exchanges between the client and server. The server and any intervening proxies must support persistent connections to successfully complete the authentication.
Digest (included due to reference in NTLM explanation above) Digest authentication is a challenge-response scheme that is intended to replace Basic authentication. The server sends a string of random data called a nonce to the client as a challenge. The client responds with a hash that includes the user name, password, and nonce, among additional information. The complexity this exchange introduces and the data hashing make it more difficult to steal and reuse the user's credentials with this authentication scheme.
Digest authentication requires the use of Windows domain accounts. The digest realm is the Windows domain name. Therefore, you cannot use a server running on an operating system that does not support Windows domains, such as Windows XP Home Edition, with Digest authentication. Conversely, when the client runs on an operating system that does not support Windows domains, a domain account must be explicitly specified during the authentication.
After upgrading from Xamarin iOS 13.10.0.17 to Xamarin iOS 14.6.0.15 we are also experiencing these problems. We have a lot of customers which still use NTLM so this is a major issue for us. The workaround is working for now but we would like to have a long term solution for this (e.g. when Xamarin moves to .NET Core 6.0).
I wrote some unittests to reproduce the problem, see: https://github.com/JeroenBer/testntlm.
Also I created a new item on dotnet runtime since this also seems like a bug in .NET Core on Mac: https://github.com/dotnet/runtime/issues/46247
What do we need to do to get this solved ? and not a temporary workaround. Also on Android the fix for now is downgrading to MonoWebRequestHandler.
We still have to use the old version Xamarin iOS 13.10.0.17. Our project contains a large number of methods, that uses HttpClient. Сode of these methods is located in shared project, that uses non only IOS. So we're still hopeful about fixing this issue!
I do not have an HttpClient so I can't use the HttpClientHandlerFactory to workaround the issue.
I am using a WebService from an .asmx file that I add as a WebReference in my Xamarin project.
Does anyone have any idea of a workaround?
I can't believe this has not been fixed yet...
I've got the first workaround integrated into my Forms app(s) and I am able to authenticate on iOS via NTLM without issues. Note that the particular workaround I am using is not the latest suggestion by MS for this issue. Their latest 'fix' as per this thread is to set that MSBuild property that supposedly rolls the Mono HTTP Client back to a legacy version.
Seeing as I can authenticate on my iOS apps through the original workaround linked above, you may want to avoid rolling the mono client back via the MSBuild property as is suggested by MS and instead use the original workaround which you can see actually only makes changes when on the Android environment:
Type androidenvType = Type.GetType("Android.Runtime.AndroidEnvironment, Mono.Android"); if (androidenvType == null) { // For non-Android systems the default HttpClientHandler works fine with NTLM via GSS // e.g. GSS.frameworks for macOS and iOS and krb5 on Linux (requires `gss-ntlmssp` package installed) return new HttpClientHandler(); }
Other than matching my approach using that workaround, I also included my build environment below so you can compare our development environments to eliminate differences and try to narrow things down.
Visual Studio Environment
Microsoft Visual Studio Enterprise 2019 Version 16.4.6 VisualStudio.16.Release/16.4.6+29905.134 Microsoft .NET Framework Version 4.8.03752 Installed Version: Enterprise Visual C++ 2019 00435-60000-00000-AA591 Microsoft Visual C++ 2019 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASP.NET and Web Tools 2019 16.4.462.24200 ASP.NET and Web Tools 2019 ASP.NET Web Frameworks and Tools 2019 16.4.462.24200 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.4.462.24200 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.4.1000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.4.462.24200 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.4.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 3.4.1-beta4-20120-08+fa984e0202af4480c0273032da49cbbdeb32c582 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 16.4.19310.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format. Extensibility Message Bus 1.2.0 (d16-2@8b56e20) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info JetBrains ReSharper Ultimate 2019.3.4 Build 193.0.20200226.112949 JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2020 JetBrains, Inc. Microsoft Azure HDInsight Azure Node 2.4.1000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.4.1000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.4.1000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21016.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.0.87+gbb515bf382 Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.5.24 (1fafd7e) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.5.11023.1 Commit Hash:579896f0984848d17d080c8a1c3ddff98d5ba96f Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 5.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Open in Sublime Text 1.1.30 Adds a menu command that lets you open any solution, project, folder and file in Sublime Text. ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Python 16.4.19310.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python - Conda support 16.4.19310.1 Conda support for Python projects. Python - Django support 16.4.19310.1 Provides templates and integration for the Django web framework. Python - IronPython support 16.4.19310.1 Provides templates and integration for IronPython-based projects. Python - Profiling support 16.4.19310.1 Profiling support for Python projects. Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.62002.03150 Microsoft SQL Server Data Tools ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.11031.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.4.1-beta4-20120-08+fa984e0202af4480c0273032da49cbbdeb32c582 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 10.4 for F# 4.6 16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354 Microsoft Visual F# Tools 10.4 for F# 4.6 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.4.000.313 (d16-4@793df40) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.4.0.475 (remotes/origin/d16-4@ac250f5aa) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.4.25 (579ee62) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 10.1.4.0 (d16-4/e44d1ae) Xamarin.Android Reference Assemblies and MSBuild support. Mono: fd9f379 Java.Interop: xamarin/java.interop/d16-4@c4e569f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b Xamarin.iOS and Xamarin.Mac SDK 13.10.0.21 (02c4b3b) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Best of luck! Let me know if there's anything I can do to help.
I can confirm that NTLM works with Xamarin.iOS SDK 13.10.0.17 but it is broken with every release after.
I testet it in the client project im currently working on.
Is there any option to downgrade the XamrinIos SDK ?
I have been avoiding the work arounds assuming there would be a fix for this issue. But with the release of iOS 15, my outdated but working version of the SDK is no longer supported. My users are getting "The developer of this app needs to update it to work with this version of iOS."
Is there a generally agreed upon work around that I should try to be able to keep my app working in iOS 15?
I have been avoiding the work arounds assuming there would be a fix for this issue. But with the release of iOS 15, my outdated but working version of the SDK is no longer supported. My users are getting "The developer of this app needs to update it to work with this version of iOS."
Is there a generally agreed upon work around that I should try to be able to keep my app working in iOS 15?
Yes can confirm that https://github.com/xamarin/xamarin-macios/issues/7770#issuecomment-610957690 is still working great for me. Also for iOS 15. I just use the latest Xamarin.ios now So get the code from that Nuget mentioned and change the code like in that post
Blake,
I just went through this same drill and found out the hard way that armv7 is no longer supported in iOS 15. For your APP to work, you will need to change the Supported Architectures in Visual Studio to ARM64 ONLY. Don't forget to change UIRequiredDeviceCapabilities in your info.plist file to ARM64 as well. Depending on your version of xcode, you will probably need to change the MinimumOSVersion in your info.plist file to 10.0.
I hope that works for you...
Barry
i facing problem when try to call an api using NtlmHttpHandlerFactory in my Xamarin.iOS application , it return Unauthorized as in screen shot
Xamarin.iOS >> Version: 15.8.0.3 Mac OS X 12.3.1
Steps to Reproduce
Expected Behavior
Request works in Visual Studio Preview 2 with Xamarin.iOS SDK 13.14.1.17
Actual Behavior
Request returns 401 Unauthorized
Environment
Build Logs
Example Project
Forms.NtlmTest.zip