-
Notifications
You must be signed in to change notification settings - Fork 253
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
GraphServiceClient hitting error 'A security error occurred' #2782
Comments
Thanks for raising this @isPhilo Are you by any chance able to replicate this if you add a reference to the latest version of this package to your project? https://www.nuget.org/packages/System.Net.Http.WinHttpHandler/#versions-body-tab |
I am already using the latest versions of the packages
|
I am trying to support TLS 1.3 in our .Net Framework 4.8 C# application. Calling GraphServiceClient gives a security error when only TLS 1.3 is enabled but works when both TLS 1.2 and 1.3 are enabled.
Error:
d__0.MoveNext() in C:\Users\administrator.xxx\Source\Repos\TestMsGraphTls13\TestMsGraphTls13\Program.cs:line 25System.Net.Http.HttpRequestException
HResult=0x80131500
Message=An error occurred while sending the request.
Source=mscorlib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.BodyInspectionHandler.d__2.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.HeadersInspectionHandler.d__2.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RedirectHandler.d__5.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.d__7.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.UriReplacementHandler
1.<SendAsync>d__2.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.<GetHttpResponseMessageAsync>d__33.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.<SendAsync>d__20
1.MoveNext()at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.Me.MeRequestBuilder.d__151.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TestMsGraphTls13.Program.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at TestMsGraphTls13.Program.(String[] args)
This exception was originally thrown at this call stack:
System.Threading.Tasks.RendezvousAwaitable.GetResult()
System.Net.Http.WinHttpHandler.StartRequestAsync(System.Net.Http.WinHttpRequestState)
Inner Exception 1:
WinHttpException: Error 12175 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A security error occurred'.
Code:
I created a standalone console app with these lines
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
string[] scopes = { "User.Read.All" };
var usernamePasswordCredential = new UsernamePasswordCredential("user", "passw!", "tenantid", "clientid");
GraphServiceClient graphClient = new GraphServiceClient(usernamePasswordCredential, scopes);
var me = await graphClient.Me.GetAsync();
Works with both TLS 1.2 and 1.3 enabled
Fails when only TLS 1.3 is enabled.
Wireshark shows connnection with login.microsoft.com using tls 1.3 but then trying to use tls 1.2 with graph.microsoft.com
Created another console app using only httpclient to get auth code and then get users from graph.microsoft.com. httpclient only code works with only tls 1.3 enabled and confirmed in wireshark.
I think this rules out most environment misconfiguration.
Does graphserviceclient and WinHttp support TLS 1.3 or am I missing some other TLS configuration for graphserviceclient to work with TLS 1.3 only.
Similar issue: #2176
Windows Server 2022 standard(updated)
Visual studio 2019
Console App for graph service client uses latest stable Dlls from nuget.
The text was updated successfully, but these errors were encountered: