Skip to content

CredentialCache.DefaultCredentials and UseDefaultCredentials on .NET8 Core #2236

@yvovonBerg

Description

@yvovonBerg

Describe the bug
It appears that CredentialCache.DefaultCredentials is being used by RestSharp but it doesn't properly pass through the credentials for some reason. It should connect through Kerberos.

To Reproduce
Does not work on .NET 8 Core:

using System.Net;
using RestSharp;

class Program
{
	static void Main(string[] args)
	{
		var options = new RestClientOptions("https://secure.server.example.com") 
		{ 
			Credentials = CredentialCache.DefaultCredentials
		};

		RestClient Client = new RestClient(options);
		var request = new RestRequest("document/EXAMPLE-1");
		var response = Client.Execute(request);
		Console.WriteLine(response.ErrorMessage);
		Console.WriteLine(response.Content);
	}
}

But does work on .NETFramework v4.8

Expected behavior
It should authenticate correctly.

Stack trace
401 response from the webserver.

Desktop (please complete the following information):

  • OS: Windows 10 Enterprise
  • .NET version: .NET 8 Core
  • Version 111.3.0

Additional context
I've also tried to use the useDefaultCredentials flag and the workaround here: dotnet/runtime#84545 of swapping the credentials and useDefaultCredentials arguments but that does not resolve the issue sadly.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions