gpt4 book ai didi

c# - netTCP 绑定(bind) Soap 安全协商失败

转载 作者:可可西里 更新时间:2023-11-01 03:06:27 30 4
gpt4 key购买 nike

我正在编写一个 WCF 服务,需要模拟和 session 。

当我试图在我的本地机器上调用它时没问题,但在远程机器上它总是失败并出现这样的错误:

Security Support Provider Interface (SSPI) authentication failed. The server may not be running in an account with identity 'host/hostname'. If the server is running in a service account (Network Service for example), specify the account's ServicePrincipalName as the identity in the EndpointAddress for the server. If the server is running in a user account, specify the account's UserPrincipalName as the identity in the EndpointAddress for the server.

如果我提供了一个 upn,它会抛出身份失败异常。

这是我的配置:

服务器配置(APP):

<system.serviceModel>    
<behaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="DataService.netTcpBinding">
<readerQuotas maxArrayLength="65535" maxBytesPerRead="2147483647" maxStringContentLength="2147483647"/>
<reliableSession enabled="true" inactivityTimeout="24:00:00" ordered="true"/>
<security mode="TransportWithMessageCredential">
<message clientCredentialType="Windows" />
<transport clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service behaviorConfiguration="default" name="DataService.DataService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="DataService.netTcpBinding"
name="DataService.DataService" contract="DataService.IDataService"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://address:4504/"/>
<add baseAddress="net.tcp://address:4503/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>

客户端配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="DataService.DataService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="24.00:00:00"
enabled="true" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://address:4503/" binding="netTcpBinding"
bindingConfiguration="DataService.DataService"
contract="ataService.IDataService" name="DataService.DataService">
<identity>
<dns value="DOMAIN"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>

如有任何帮助,我们将不胜感激。

最佳答案

Windows 服务使用用户主体名称或服务主体名称 (documentation) 注册自己。引用该链接:“如果服务在 LocalSystem、LocalService 或 NetworkService 帐户下运行,默认情况下会以主机/的形式生成服务主体名称 (SPN),因为这些帐户可以访问计算机的SPN 数据。如果该服务在不同的帐户下运行,Windows Communication Foundation (WCF) 会生成 @ 形式的 UPN。“事实上,这句话与您的错误消息所陈述的内容非常相似。看来……

a) 如果该服务在本地服务帐户或类似的标准帐户下运行,那么您需要调整您的客户端配置文件以拥有它,其中实际服务器的名称是“地址”并且端点在端口 4503 上运行:

<identity>
<servicePrincipalName value="host/address:4503" />
</identity>

b) 或者,如果您在专用服务帐户下运行(我们在域“MyDomain”上将其称为“ServiceAccount”),那么您需要

<identity>
<userPrincipalName value="ServiceAccount@MyDomain" />
</identity>

请注意,您可能需要在两种情况下都使用完全限定的域名,包括森林和树木级别。对于私有(private) LAN/WAN 内的简单域,这意味着 address.MyDomain.local 和 ServiceAccount@MyDomain.local。如果您的域位于名为 MyTree 的树中,那么它将是 ServiceAccount@MyDomain.MyTree.local;如果它位于名为 MyForest 的林中,则它将是 Serviceaccount@MyDomain.MyTree.MyForest.local(对于 ServicePrincipalName 也是类似的)。需要完全限定名称 when you are using Kerberos用于身份验证。

关于c# - netTCP 绑定(bind) Soap 安全协商失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9683182/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com