Xml WCF:使用客户端时出现SecurityNegotiationException
所以我一直在尝试为我的客户机和服务设置证书身份验证。最终的目标是根据客户端连接的证书对数据进行分区(即,证书成为其在更大系统中的凭据,并且根据这些凭据对其数据进行分区) 我已经能够在客户端和服务器端成功地设置它。我已经创建了一个证书和一个私钥,将它们安装在我的计算机上,并设置了我的服务器,以便1)它有一个基于证书的服务凭据,2)如果客户端连接时没有提供基于证书的凭据,则会引发异常 然后,我创建了一个简单的客户端,并将证书凭据添加到配置中,然后尝试调用服务上的一个简单操作 看起来客户端连接正常,并且服务器接受了证书,但我得到了以下信息: SecurityNegotiationException: “服务未对调用方进行身份验证。” 这对我来说似乎有点模棱两可。请注意,我使用的是wsHttpBinding,出于传输安全性考虑,它默认为Windows auth…但所有这些进程都是在调试环境中以我的用户帐户运行的 以下是我的服务器配置:Xml WCF:使用客户端时出现SecurityNegotiationException,xml,wcf,certificate,wshttpbinding,Xml,Wcf,Certificate,Wshttpbinding,所以我一直在尝试为我的客户机和服务设置证书身份验证。最终的目标是根据客户端连接的证书对数据进行分区(即,证书成为其在更大系统中的凭据,并且根据这些凭据对其数据进行分区) 我已经能够在客户端和服务器端成功地设置它。我已经创建了一个证书和一个私钥,将它们安装在我的计算机上,并设置了我的服务器,以便1)它有一个基于证书的服务凭据,2)如果客户端连接时没有提供基于证书的凭据,则会引发异常 然后,我创建了一个简单的客户端,并将证书凭据添加到配置中,然后尝试调用服务上的一个简单操作 看起来客户端连接正常,并
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyServiceBinding">
<security mode="Message">
<transport clientCredentialType="None"/>
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint binding="wsHttpBinding" bindingConfiguration="MyServiceBinding" contract="IMyContract"/>
<endpoint binding="mexHttpBinding" address="mex" contract="IMetadataExchange">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<serviceCertificate storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" findValue="tmp123"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
这是我的客户端配置--请注意,我使用的客户端证书与我在服务上使用的证书相同:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<!--<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>-->
<message clientCredentialType="Certificate" negotiateServiceCredential="true" algorithmSuite="Default"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:50120/UserServices.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" behaviorConfiguration="IMyService_Behavior" contract="UserServices.IUserServices" name="WSHttpBinding_IMyService">
<identity>
<certificate encodedValue="Some RSA stuff"/>
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="IMyService_Behavior">
<clientCredentials>
<clientCertificate storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" findValue="tmp123"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
任何人都可以提供一些关于这里可能发生的事情的见解吗
谢谢,看不到任何明显的内容,但请查看此链接,可能会看到您缺少的内容。我在指南中注意到的一件事是,服务器配置标识块被注释掉了。是的,我试图删除它,但没有效果——同样的问题。我还尝试为客户端和服务生成一个证书,但也没有效果。我想知道该服务如何知道要接受哪些证书…配置中没有映射,看起来…它只是运行该服务的用户的可信证书吗?