Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpClient with NTLM auth returns 401 Unauthorized with Xamarin.iOS SDK 13.14.1.17 #7770

Open
CerealGuy93 opened this issue Jan 29, 2020 · 53 comments
Assignees
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS networking If an issue or pull request is related to networking
Milestone

Comments

@CerealGuy93
Copy link

Steps to Reproduce

  1. Download attached project (Forms.NtlmTest)
  2. Change server, username and password in MainPage.xaml.cs
  3. Build with the latest Visual Studio (with Xamarin.iOS SDK 13.10.0.17) and click on connect (in the app) => Working
  4. Clean project (delete bin/obj in ios and forms project)
  5. Build with latest Visual Studio Preview (16.5 Preview 2, with Xamarin.iOS SDK 13.14.1.17) and click on connect (in the app) => Not working

Expected Behavior

Request works in Visual Studio Preview 2 with Xamarin.iOS SDK 13.14.1.17

Actual Behavior

Request returns 401 Unauthorized

Environment

Microsoft Visual Studio Professional 2019 Preview
Version 16.5.0 Preview 2.0
VisualStudio.16.Preview/16.5.0-pre.2.0+29721.120
Microsoft .NET Framework
Version 4.8.03752

Installierte Version: Professional

Allgemeine Azure-Tools   1.10
Bietet allgemeine Dienste für die Verwendung durch Azure Mobile Services und Microsoft Azure-Tools.

ASP.NET and Web Tools 2019   16.5.170.20430
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   16.5.170.20430
Weitere Informationen finden Sie unter https://www.asp.net/.

Azure App Service-Tools v3.0.0   16.5.170.20430
Azure App Service-Tools v3.0.0

Azure Functions and Web Jobs Tools   16.5.170.20430
Azure Functions and Web Jobs Tools

C#-Tools   3.5.0-beta2-20057-04+f43cfcd2be1b781e0b5a9153776f7e5fecf92b89
C#-Komponenten, die in der IDE verwendet werden. Abhängig von Ihrem Projekttyp und den zugehörigen Einstellungen kann eine andere Version des Compilers verwendet werden.

Erweiterungen der Visual Studio-Containertools (Vorschau)   1.0
Hiermit werden Container in Visual Studio angezeigt, verwaltet und diagnostiziert.

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.

IntelliCode-Erweiterung   1.0
Detaillierte Informationen zur IntelliCode Visual Studio-Erweiterung

JetBrains ReSharper Ultimate 2019.3.1   Build 193.0.20191219.91525
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-Tools   2.9
Microsoft Azure-Tools für Microsoft Visual Studio 2019 – v2.9.21108.1

Microsoft Continuous Delivery Tools für Visual Studio   0.4
Die Konfiguration von Azure DevOps-Pipelines von der Visual Studio-IDE aus wird vereinfacht.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio-Tools für Container   1.1
Jetzt können Sie Ihre ASP.NET Core-Anwendung in der Zielumgebung entwickeln, ausführen und überprüfen. Drücken Sie F5, um die Anwendung direkt in einem Container mit Debugfunktionen auszuführen, oder STRG+F5 zum Bearbeiten und Aktualisieren Ihrer Anwendung, ohne den Container erneut erstellen zu müssen.

Mono Debugging for Visual Studio   16.5.509 (d15be8b)
Support for debugging Mono processes with Visual Studio.

Node.js-Tools   1.5.11120.1 Commit Hash:a426edc95ecb37f7b327f30b3d7ad49d1b87b69a
Fügt Unterstützung für das Entwickeln und Debuggen von Node.js-Apps in Visual Studio hinzu

NuGet-Paket-Manager   5.5.0
NuGet-Paket-Manager in Visual Studio. Weitere Informationen zu NuGet finden Sie unter https://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.62001.16180
Microsoft SQL Server Data Tools

TypeScript-Tools   16.0.20113.2001
TypeScript-Tools für Microsoft Visual Studio

Visual Basic-Tools   3.5.0-beta2-20057-04+f43cfcd2be1b781e0b5a9153776f7e5fecf92b89
Visual Basic-Komponenten, die in der IDE verwendet werden. Abhängig von Ihrem Projekttyp und den zugehörigen Einstellungen kann eine andere Version des Compilers verwendet werden.

Visual F# Tools 10.8.0.0 für F# 4.7   16.5.0-beta.20071.14+c4c09df4d5a68c3e9a51948bab554d11e2c141f2
Microsoft Visual F# Tools 10.8.0.0 für f# 4.7

Visual Studio-Tools für Container   1.0
Visual Studio-Tools für Container

Visual Studio Code-Debugadapter-Hostpaket   1.0
Interopebene zum Hosten der Visual Studio Code-Adapter in Visual Studio

VisualStudio.DeviceLog   1.0
Informationen zum Paket

VisualStudio.Foo   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   16.5.000.400 (d16-5@4a7a7df)
Visual Studio-Erweiterung, um Entwicklung für Xamarin.iOS und Xamarin.Android zu ermöglichen.

Xamarin Designer   16.5.0.391 (remotes/origin/d16-5@2aeef9a0a)
Visual Studio-Erweiterung zum Aktivieren der Xamarin Designer-Tools in Visual Studio.

Xamarin Templates   16.5.42 (afa79c5)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   10.2.0.84 (d16-5/ac3f71f)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: df42020
    Java.Interop: xamarin/java.interop/d16-5@c0cc770
    ProGuard: xamarin/proguard/master@905836d
    SQLite: xamarin/sqlite/3.28.0@46204c4
    Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b


Xamarin.iOS and Xamarin.Mac SDK   13.14.1.17 (d308800)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

Using Xcode 11.3.1 found in /Applications/Xcode.app/Contents/Developer
Xamarin.Hosting: Xamarin.Hosting
Xamarin.Hosting:     Version: f56575dcc2 (d16-5)
Xamarin.Hosting:     Xcode: /Applications/Xcode.app
Xamarin.Hosting:     Xcode Version: 11.3.1
Xamarin.Hosting:     Verbosity: 1
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTiPhoneSimulatorRemoteClient.framework/DVTiPhoneSimulatorRemoteClient
Xamarin.Hosting: Loaded /Library/Developer/PrivateFrameworks/CoreSimulator.framework/CoreSimulator
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/DTDeviceKitBase
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/DVTKit
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKit.framework/DTDeviceKit
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTXConnectionServices.framework/DTXConnectionServices
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTSourceControl.framework/DVTSourceControl
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTServices.framework/DVTServices
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTPortal.framework/DVTPortal
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTDocumentation.framework/DVTDocumentation
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTAnalyticsClient.framework/DVTAnalyticsClient
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTAnalytics.framework/DVTAnalytics
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/SourceKit.framework/SourceKit
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework/IDEFoundation
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/IDEProducts.framework/IDEProducts
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DTGraphKit.framework/DTGraphKit
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DVTDeveloperModeHelper.framework/DVTDeveloperModeHelper
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/IDEKit
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IBFoundation.framework/IBFoundation
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/Frameworks/IBAutolayoutFoundation.framework/IBAutolayoutFoundation
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DebugHierarchyFoundation.framework/DebugHierarchyFoundation
Xamarin.Hosting: Loaded /Applications/Xcode.app/Contents/SharedFrameworks/DebugHierarchyKit.framework/DebugHierarchyKit
Xamarin.Hosting: Loaded Xcode plugins successfully.
Xamarin.Hosting: Device discovery started
Xamarin.Hosting: Device discovery event: Connected (d273c5de64deaac5b7c4ab842334f0f4283565e7)
Xamarin.Hosting: Connected to Entwicklungsiphone (d273c5de64deaac5b7c4ab842334f0f4283565e7) in 00:00:00.0018793
Xamarin.Hosting: Connecting to 'Entwicklungsiphone', token is 0x7fc56662c300
Xamarin.Hosting: Connected to 'Entwicklungsiphone'
Xamarin.Hosting: Mounting developer image on 'Entwicklungsiphone'
Xamarin.Hosting: Mounted developer image on 'Entwicklungsiphone'
Xamarin.Hosting: Launched com.companyname.Forms.NtlmTest with PID: 1584
Launched application 'com.companyname.Forms.NtlmTest' on 'Entwicklungsiphone' with pid 1584
2020-01-29 10:24:13.962 Forms.NtlmTest.iOS[1584:1549811] Xamarin.iOS: IDE Port: 10000 Transport: USB
2020-01-29 10:24:14.127 Forms.NtlmTest.iOS[1584:1549811] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 4
2020-01-29 10:24:14.127 Forms.NtlmTest.iOS[1584:1549811] Xamarin.iOS: Processing: 'start debugger: sdb'
2020-01-29 10:24:14.128 Forms.NtlmTest.iOS[1584:1549811] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 5
2020-01-29 10:24:14.129 Forms.NtlmTest.iOS[1584:1549811] Xamarin.iOS: Processing: 'connect output'
Starten war erfolgreich. Die Anwendung "Forms.NtlmTest.iOS" wurde erfolgreich auf "Entwicklungsiphone" gestartet.

Example Project

Forms.NtlmTest.zip

@CerealGuy93 CerealGuy93 changed the title NTLM returns 401 Unauthorized with Xamarin.iOS SDK 13.14.1.17 HttpClient with NTLM auth returns 401 Unauthorized with Xamarin.iOS SDK 13.14.1.17 Jan 29, 2020
@chamons chamons added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS labels Jan 29, 2020
@chamons chamons added this to the Future milestone Jan 29, 2020
@dfoulk
Copy link

dfoulk commented Feb 12, 2020

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

@steveisok
Copy link
Contributor

@dfoulk No, the issue that impacts android boils down to the native library that socketshttphandler depends on is not supported on android.

@BlakeMartin838
Copy link

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?

@CerealGuy93
Copy link
Author

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

@BlakeMartin838
Copy link

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/ ?

@steveisok
Copy link
Contributor

@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.

@BlakeMartin838
Copy link

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?

@CerealGuy93
Copy link
Author

CerealGuy93 commented Mar 19, 2020

@steveisok i tried it with a .net core application against the same API and the requests are working.

@steveisok
Copy link
Contributor

@CerealGuy93 Thanks. What is your server setup?

@BlakeMartin838
Copy link

@CerealGuy93 @steveisok , are we talking .net core on the Xamarin side or the server/web service side?

@steveisok
Copy link
Contributor

@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.

@CerealGuy93
Copy link
Author

@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

@BlakeMartin838
Copy link

@steveisok Is there anything else you need in order to implement a fix for this for Xamarian.iOS like you did for Xamarin.Android?

@steveisok
Copy link
Contributor

@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.

@mooola
Copy link

mooola commented Mar 20, 2020

@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?

@steveisok
Copy link
Contributor

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.

@CerealGuy93
Copy link
Author

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.

@BlakeMartin838
Copy link

@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?

@CerealGuy93
Copy link
Author

@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

@dfoulk
Copy link

dfoulk commented Mar 20, 2020

We've now had issues with NTLM authentication in Xamarin.Forms since October of 2019. Please prioritize this issue.

@CerealGuy93
Copy link
Author

@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.

@BlakeMartin838
Copy link

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"

@steveisok
Copy link
Contributor

@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.

@dfoulk
Copy link

dfoulk commented Apr 2, 2020

@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. 😑

My VS2019 Environment

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.

@dfoulk
Copy link

dfoulk commented Apr 2, 2020

@nwhittle Are iOS builds on your machine still performing NTLM authentication successfully? If so, can you post your environment info here, please?

@dfoulk
Copy link

dfoulk commented Apr 23, 2020

@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?

@steveisok
Copy link
Contributor

@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.

@CerealGuy93
Copy link
Author

@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?

@mandel-macaque mandel-macaque added the networking If an issue or pull request is related to networking label May 6, 2020
@mandel-macaque
Copy link
Member

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.

@vniehues
Copy link

vniehues commented May 26, 2020

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.

@mnidhk
Copy link

mnidhk commented Jun 5, 2020

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!

@BlakeMartin838
Copy link

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.

@mnidhk
Copy link

mnidhk commented Jun 29, 2020

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!?

@grimmi
Copy link

grimmi commented Jul 9, 2020

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?

@bburtonpa
Copy link

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!!!

@dfoulk
Copy link

dfoulk commented Jul 22, 2020

@bburtonpa I think we are S.O.L. until (at the earliest) November 2020, when .NET 5 is released.

@bburtonpa
Copy link

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...

@BlakeMartin838
Copy link

I was able to confirm that @bburtonpa method works but is using Basic Authentication in an app over HTTPS secure?

@dfoulk
Copy link

dfoulk commented Sep 28, 2020

@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.

Source: https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/understanding-http-authentication

@JeroenBer
Copy link

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: dotnet/runtime#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.

@Transflyer
Copy link

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!

@thinkjohn
Copy link

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...

@anurag-sukumaran
Copy link

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 ?

@BlakeMartin838
Copy link

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?

@mnidhk
Copy link

mnidhk commented Sep 21, 2021

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 #7770 (comment) 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

@bburtonpa
Copy link

bburtonpa commented Sep 22, 2021

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

@AhmedAdelGadElkareeem
Copy link

AhmedAdelGadElkareeem commented May 12, 2022

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

Screen Shot 2022-05-12 at 1 57 54 PM

@vinhdp195
Copy link

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

Screen Shot 2022-05-12 at 1 57 54 PM

I also got the same error as above
Please help

@vinhdp195
Copy link

@AhmedAdelGadElkareeem Do you have any solution to fix the error?

@AhmedAdelGadElkareeem
Copy link

AhmedAdelGadElkareeem commented Mar 29, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS networking If an issue or pull request is related to networking
Projects
None yet
Development

No branches or pull requests