gpt4 book ai didi

c# - 更改证书后的 WCF SOAP 安全协商

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:45 25 4
gpt4 key购买 nike

在我将自签名证书“​​localhost”(DNS=localhost) 更改为“Cloudflare Origin Certificate”(dns=mydomain.com) 后,出现以下错误:

SOAP security negotiation with 'http://localhost:8000/MyService.svc' for target 'http://localhost:8000/MyService.svc' failed. See inner exception for more details.

内部异常:

Either the client credential was invalid or there was an error collecting the client credentials by the SSPI.

我注意到在启动客户端后,我得到了输入凭据的窗口。不知道为什么。

我到底做了什么:

  1. 在 IIS 中生成证书请求
  2. 完成 CloudFlare 证书
  3. 使用 CloudFlare Root CA 收到粘贴到文本文件中的 key
  4. 完成 IIS(个人、本地计算机)证书
  5. 在添加到 Trusted Publishers CloudFlare Root CA (LocalMachine) 的 MMC 中
  6. 对于 WCF 网站,将 SSL 证书更改为 CloudFlare
  7. 客户端值从“localhost”更改为“mydomain.com”
  8. 将服务器值从“localhost”更改为“mydomain.com”
  9. 更改了
  10. 的 findValue

WCF web.config

<system.serviceModel>
<client />
<behaviors>
<serviceBehaviors>
<behavior name="authBehavior">
<serviceAuthorization principalPermissionMode="UseWindowsGroups">
<authorizationPolicies>
<add policyType="WCF.Common.AuthorizationPolicy, WCF" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCF.Common.IdentityValidator, WCF" />
<serviceCertificate findValue="CloudFlare Origin Certificate" storeLocation="LocalMachine" x509FindType="FindBySubjectName" storeName="My" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="svcBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpsBinding>
<binding name="basicHttpsEndpointBinding" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" maxBufferPoolSize="1073741824">
<readerQuotas maxDepth="32" maxArrayLength="1073741824" maxStringContentLength="1073741824" />
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpsBinding>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding"></binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WCF.MyService" behaviorConfiguration="svcBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" contract="WCF.IMyService">
<identity>
<dns value="mydomain.com" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

客户端应用程序配置

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
<binding name="WSHttpBinding_IMyService" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8777/MyService.svc"
binding="wsHttpBinding" contract="WCF.IMyService"
name="WSHttpBinding_IMyService">
<identity>
<dns value="mydomain.com" />
</identity>
</endpoint>
</client>

<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

我在我的 WCF 中托管其他服务,也在客户端中托管一些服务,但它们都不是必需的。

我在 WCF 和客户端之间使用 wsHttpBindings。我该怎么做才能摆脱这个错误?

使用 wsHttpBinding 等的目的是什么...:只允许此客户端与 MyService 通信。不允许其他任何人。客户端应用程序将在域中的多台计算机上运行。您是否建议使用不同的方法?

谢谢你的想法!

编辑:出现错误的计算机未在域中运行。既不适用于域中的计算机:/

EDIT2:安全模式传输WCF web.config 绑定(bind):

<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport">
<message clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>

客户端配置绑定(bind):

<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService">
<security mode="Transport">
<message clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:8001/MyService.svc"
binding="wsHttpBinding" contract="WCF.IMyService"
name="WSHttpBinding_IMyService">
<identity>
<dns value="mydomain.com" />
</identity>
</endpoint>
</client>

IIS: Certificate

最佳答案

这里有一些资源可供查看,以帮助确定 NetTcpBinding 是否适合您,这听起来像是,因为您正在内部使用 Web 服务。

NetTcpBinding当 WCF 服务及其客户端位于 Intranet 基础结构中时,netTcpBinding 是最佳选择。由于它只支持TCP协议(protocol),不支持HTTP,所以无法通过互联网访问服务。

这是安全绑定(bind),用于在 Intranet 计算机中发送二进制编码的 SOAP 消息。它支持可靠性、事务性和安全性。如果您在 IIS 中使用 netTcpBinding 和主机 WCF 服务,您需要在系统和 IIS 上进行一些设置 this article将帮助您进行所需的设置。

解决相关问题的一些技巧:

  • 双击 MMC 中的证书是否会给您任何错误消息在证书信息标题下?
  • 您能否在浏览器中从您的客户端浏览服务?
  • 是否在 IIS 中分配了证书
  • 你的绑定(bind)是否正确
  • 客户端是否使用与服务主机相同的绑定(bind)?
  • 您的端点是否引用了正确的绑定(bind)和服务行为

有关 NetTcpBinding 的其他有用信息:

https://stackoverflow.com/a/3375161/2016162

关于c# - 更改证书后的 WCF SOAP 安全协商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53750262/

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