Wpf Authentication does not work on .Net 8
Opened this issue · 1 comments
Trying to run the Wpf sample will result in the Wpf.exe client throwing an unhandled exception due to trying to connect to the NamedPipeServerStream.
Here is a snippet of Windows Event logs from the crash
Application: Wpf.exe CoreCLR Version: 8.0.724.31311 .NET Version: 8.0.7 Description: The process was terminated due to an unhandled exception. Exception Info: System.UnauthorizedAccessException: Access to the path is denied. at System.IO.Pipes.NamedPipeClientStream.TryConnect(Int32 timeout) at System.IO.Pipes.NamedPipeClientStream.ConnectInternal(Int32 timeout, CancellationToken cancellationToken, Int32 startTime) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location.
From what I have found, using this solution seems to work, but I would rather have a solution using the built in named pipe server.
It seems the fix is to use NamedPipeServerStreamAcl
instead of NamedPipeServerStream
var pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(
new PipeAccessRule(
new SecurityIdentifier(
WellKnownSidType.BuiltinUsersSid,
null
),
PipeAccessRights.ReadWrite,
AccessControlType.Allow
));
using var server = NamedPipeServerStreamAcl.Create(_name, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous | PipeOptions.WriteThrough, default, default, pipeSecurity);
await server.WaitForConnectionAsync();