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

Test failure with "Provider could not perform the action since the context was acquired as silent" #29419

Closed
stephentoub opened this issue May 1, 2019 · 6 comments · Fixed by #100496
Assignees
Labels
area-System.Net.Http disabled-test The test is disabled in source code against the issue in-pr There is an active PR which will close this issue when it is merged test-bug Problem in test source code (most likely) test-run-core Test failures in .NET Core test runs
Milestone

Comments

@stephentoub
Copy link
Member

I've been seeing this error not-infrequently in local System.Net.Http test runs.
"Error -2146893790 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Provider could not perform the action since the context was acquired as silent.'"

System.Net.Http.Functional.Tests.PlatformHandler_HttpClientHandler_ClientCertificates_Test.AutomaticOrManual_DoesntFailRegardlessOfWhetherClientCertsAreAvailable(mode: Automatic) [FAIL]
        System.AggregateException : One or more errors occurred. (One or more errors occurred. (An error occurred while sending the request.)) (One or more errors occurred. (Authentication failed because the remote party has closed the transport stream.))
        ---- System.AggregateException : One or more errors occurred. (An error occurred while sending the request.)
        -------- System.Net.Http.HttpRequestException : An error occurred while sending the request.
        ------------ System.Net.Http.WinHttpException : Error -2146893790 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'Provider could not perform the action since the context was acquired as silent.'.
        ---- System.AggregateException : One or more errors occurred. (Authentication failed because the remote party has closed the transport stream.)
        -------- System.IO.IOException : Authentication failed because the remote party has closed the transport stream.
        Stack Trace:
          D:\repos\corefx\src\Common\tests\System\Threading\Tasks\TaskTimeoutExtensions.cs(111,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
          D:\repos\corefx\src\System.Net.Http\tests\FunctionalTests\HttpClientHandlerTest.ClientCertificates.cs(286,0): at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass14_0.<<AutomaticOrManual_DoesntFailRegardlessOfWhetherClientCertsAreAvailable>b__1>d.MoveNext()
          --- End of stack trace from previous location where exception was thrown ---
          D:\repos\corefx\src\Common\tests\System\Net\Http\LoopbackServer.cs(66,0): at System.Net.Test.Common.LoopbackServer.CreateServerAsync(Func`2 funcAsync, Options options)
          D:\repos\corefx\src\System.Net.Http\tests\FunctionalTests\HttpClientHandlerTest.ClientCertificates.cs(277,0): at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.AutomaticOrManual_DoesntFailRegardlessOfWhetherClientCertsAreAvailable(ClientCertificateOption mode)
          --- End of stack trace from previous location where exception was thrown ---
          ----- Inner Stack Trace dotnet/corefx#1 (System.AggregateException) -----

          ----- Inner Stack Trace -----
          D:\repos\corefx\src\System.Net.Http\src\System\Net\Http\HttpClient.cs(507,0): at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
          D:\repos\corefx\src\System.Net.Http\src\System\Net\Http\HttpClient.cs(135,0): at System.Net.Http.HttpClient.GetStringAsyncCore(Task`1 getTask)
          D:\repos\corefx\src\Common\tests\System\Threading\Tasks\TaskTimeoutExtensions.cs(83,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
          ----- Inner Stack Trace -----
          F:\workspace\_work\1\s\src\System.Private.CoreLib\src\System\Environment.CoreCLR.cs(97,0): at System.Environment.get_StackTrace()
          D:\repos\corefx\src\Common\src\System\Runtime\ExceptionServices\ExceptionStackTrace.cs(23,0): at System.Runtime.ExceptionServices.ExceptionStackTrace.AddCurrentStack(Exception exception)
          D:\repos\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpException.cs(57,0): at System.Net.Http.WinHttpException.CreateExceptionUsingError(Int32 error, String nameOfCalledFunction)
          D:\repos\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpRequestCallback.cs(333,0): at System.Net.Http.WinHttpRequestCallback.OnRequestError(WinHttpRequestState state, WINHTTP_ASYNC_RESULT asyncResult)
          D:\repos\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpRequestCallback.cs(104,0): at System.Net.Http.WinHttpRequestCallback.RequestCallback(IntPtr handle, WinHttpRequestState state, UInt32 internetStatus, IntPtr statusInformation, UInt32 statusInformationLength)
          D:\repos\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpRequestCallback.cs(47,0): at System.Net.Http.WinHttpRequestCallback.WinHttpCallback(IntPtr handle, IntPtr context, UInt32 internetStatus, IntPtr statusInformation, UInt32 statusInformationLength)
          --- End of stack trace from AddCurrentStack ---
          D:\repos\corefx\src\Common\src\System\Threading\Tasks\RendezvousAwaitable.cs(62,0): at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
          D:\repos\corefx\src\System.Net.Http.WinHttpHandler\src\System\Net\Http\WinHttpHandler.cs(878,0): at System.Net.Http.WinHttpHandler.StartRequest(WinHttpRequestState state)
          ----- Inner Stack Trace dotnet/corefx#2 (System.AggregateException) -----

          ----- Inner Stack Trace -----
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(611,0): at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(831,0): at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
          --- End of stack trace from previous location where exception was thrown ---
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(82,0): at System.Net.Security.SslStream.ThrowIfExceptional()
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(472,0): at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(442,0): at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.cs(284,0): at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
          D:\repos\corefx\src\System.Net.Security\src\System\Net\Security\SslStream.cs(430,0): at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__68_2(IAsyncResult iar)
          F:\workspace\_work\1\s\src\System.Private.CoreLib\shared\System\Threading\Tasks\FutureFactory.cs(514,0): at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
          --- End of stack trace from previous location where exception was thrown ---
          D:\repos\corefx\src\Common\tests\System\Net\Http\LoopbackServer.cs(100,0): at System.Net.Test.Common.LoopbackServer.AcceptConnectionAsync(Func`2 funcAsync)
@davidsh
Copy link
Contributor

davidsh commented May 1, 2019

image

I've never seen this error before.

Here's some more info:

https://docs.microsoft.com/en-us/windows/desktop/api/wincrypt/nf-wincrypt-cryptacquirecontexta

CRYPT_SILENT
The application requests that the CSP not display any user interface (UI) for this context. If the CSP must display the UI to operate, the call fails and the NTE_SILENT_CONTEXT error code is set as the last error. In addition, if calls are made to CryptGenKey with the CRYPT_USER_PROTECTED flag with a context that has been acquired with the CRYPT_SILENT flag, the calls fail and the CSP sets NTE_SILENT_CONTEXT.
CRYPT_SILENT is intended for use with applications for which the UI cannot be displayed by the CSP.

@davidsh
Copy link
Contributor

davidsh commented May 1, 2019

This is a test bug. The problem is that the test:

System.Net.Http.Functional.Tests.PlatformHandler_HttpClientHandler_ClientCertificates_Test.AutomaticOrManual_DoesntFailRegardlessOfWhetherClientCertsAreAvailable

is trying to use a client certificate via 'Automatic' selection. That can have random effects on different machines. It's probably picking a certificate on your machine in the PerUser/MY store that requires user consent, i.e. a smart-card PIN or something. But the UI is disabled in System.Net layer. So, WinHTTP is returning this error.

We probably should disable this test and try to fix it later.

@stephentoub
Copy link
Member Author

Thanks, David. I'll disable it.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 5.0 milestone Feb 1, 2020
@karelz karelz added the test-run-core Test failures in .NET Core test runs label May 7, 2020
@karelz karelz modified the milestones: 5.0, Future May 7, 2020
@ManickaP ManickaP modified the milestones: Future, 9.0.0 Sep 20, 2023
@ManickaP
Copy link
Member

Triage: either try to fix the test or get rid of it for WinHttpHandler.

@wfurt
Copy link
Member

wfurt commented Nov 4, 2023

Could you please give it another try @stephentoub? (e.g. enable the test locally and run it) I could not reproduce it locally. We can perhaps catch this specific error and turn it into TestSkip. It seems like this was not failing in CI so it would still be better than keeping it disabled without path forward. Please let me know.

@wfurt wfurt self-assigned this Nov 4, 2023
@stephentoub
Copy link
Member Author

@wfurt, sorry, I missed your question back in Nov. I just tried with the latest in main with the [ActiveIssue] removed, running the test suites for both System.Net.Http and System.Net.Http.WinHttpHandler, and everything passes. If no one else is hitting this, feel free to reactivate it. Thanks.

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Apr 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Http disabled-test The test is disabled in source code against the issue in-pr There is an active PR which will close this issue when it is merged test-bug Problem in test source code (most likely) test-run-core Test failures in .NET Core test runs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants