Named Pipe Transport Security

Hello,

I am attempting to enable transport security over a named pipe binding and I'm receiving the following error:

System.ServiceModel.Security.SecurityNegotiationException: The server has rejected the client credentials. > System.Security.Authentication.InvalidCredentialException: The server has rejected the client credentials. > System.ComponentModel.Win32Exception: The logon attempt failed

End of inner exception stack trace

at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)

at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)

at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)

End of inner exception stack trace

This is my binding:

<netNamedPipeBinding>

<bindingname="PrivateServiceBinding"closeTimeout="00:00:20"

receiveTimeout="00:00:30"sendTimeout="00:00:30">

<securitymode="Transport" />

</binding>

</netNamedPipeBinding>

If I switch to a TCP binding, my service works:

<netTcpBinding>

<bindingname="PrivateServiceBinding"closeTimeout="00:00:20"

receiveTimeout="00:00:30"sendTimeout="00:00:30">

<securitymode="Transport">

<transportclientCredentialType="Windows"protectionLevel="EncryptAndSign" />

</security>

</binding>

</netTcpBinding>

Client and server are on the same machine. Any idea why I'd be seeing a failure with named pipes? Several of my services are local only, but they require impersonation.

I'd prefer to use named pipes if possible for performance reasons. And, my services are hosted in different app domains within the same process, so going TCP would require me to eat up a lot of ports or require the user to enable the port sharing service.

[9296 byte] By [AaronOneal] at [2007-12-24]
# 1

Read this post by Kenny: http://kennyw.com/indigo/102

MicheleLerouxBustamante at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2

This part sounds like what I need:

"However, if the target SPN passed to SSPI is a well formed SPN for the local computer account (e.g. host/[dns machine name]) then Negotiate will use NTLM (loopback optimization) and the access token will not have the Network SID (and therefore will be usable with NetNamedPipes)."

So, I need to get it to use NTLM. What is the procedure for setting the SPN to achieve this? I tried specifying an identity on my service endpoint to match the hostname, but I still received the same error.

AaronOneal at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3

try either the machine name (with a trailing $), e.g. SERVER$ or "host/server.domain.local"

dominick.baier at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 4

Thanks, but unfortunately that didn't work either. I tried both formats. Here's a sample configuration that approximates my setup. Spot anything amiss?

<system.serviceModel>

<client>

<endpoint

address="net.pipe://MyRoot/Service"

binding="netNamedPipeBinding" bindingConfiguration="PrivateServiceImpersonationBinding"

behaviorConfiguration="PrivateClientBehavior"

contract="IService"

name="Service">

<identity>

<servicePrincipalName value="MYSERVER$"/>

</identity>

</endpoint>

</client>

<services>

<service name="Service" behaviorConfiguration="PrivateServiceBehavior">

<host>

<baseAddresses>

<add baseAddress="net.pipe://MyRoot/Service" />

</baseAddresses>

</host>

<endpoint binding="netNamedPipeBinding" bindingConfiguration="PrivateServiceImpersonationBinding"

name="ServiceEndpoint" contract="IService"

listenUriMode="Explicit">

<identity>

<servicePrincipalName value="MYSERVER$"/>

</identity>

</endpoint>

</service>

</services>

<bindings>

<netNamedPipeBinding>

<binding name="PrivateServiceImpersonationBinding" closeTimeout="00:00:20"

receiveTimeout="00:00:30" sendTimeout="00:00:30">

<security mode="Transport" />

</binding>

</netNamedPipeBinding>

</bindings>

<behaviors>

<endpointBehaviors>

<behavior name="PrivateClientBehavior">

<clientCredentials>

<windows allowedImpersonationLevel="Impersonation" />

</clientCredentials>

</behavior>

</endpointBehaviors>

<serviceBehaviors>

<behavior name="PrivateServiceBehavior">

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

</system.serviceModel>

AaronOneal at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 5

just to double check - is this machine a domain member or standalone?

dominick.baier at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 6
It's a standalone workstation with the client and service host on the same machine.
AaronOneal at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 7

aha - Kenny's post was about domain environments...

Then I don't understand the problem. I have the same test setup here and it works fine.

Try localhost as the machine name.

<client>
<endpoint address="net.pipe://localhost/PetShop"
binding="netNamedPipeBinding"
contract="IPetStore" />
</client>

and

<client>
<endpoint address="net.pipe://localhost/PetShop"
binding="netNamedPipeBinding"
contract="IPetStore" />
</client>

dominick.baier at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 8

I'm pretty sure all named pipes are local, so the value following net.pipe:// is the pipe name and not the server name. I only experience this issue when I turn on security:

<security mode="Transport" />

When it's off, the service works as expected (but without impersonation):

<security mode="None" />

AaronOneal at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 9

still works for me...

try localhost - i once had the same error message, and it was fixes by using localhost...

dominick.baier at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 10
You're absolutely right, replacing it with localhost or even 127.0.0.1 works perfectly. Thank you!!!
AaronOneal at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified