gpt4 book ai didi

asp.net - 在 DMZ 中运行安全 WCF 服务时出现问题

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

我在处理两个使用 WCF 服务相互通信的 Web 应用程序时遇到了一些问题。这是我的场景:

  • Web 应用程序“A”部署在企业内网的服务器和域“intranet”的一部分
  • Web 应用程序“B”部署在 DMZ 的服务器中,暴露于互联网和域“extranet”的一部分
  • 两个域之间有防火墙,没有信任关系。
  • “A”使用 wsHttpBinding 调用“B”中的一些 WCF 服务
  • “B”中的 WCF 服务在 IIS 上的 SSL 下是安全传输的。
  • 我们正在使用用户名认证行为来认证“A”

这是服务器绑定(bind)配置:

">

<binding name="UsernameWithTransport">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"
negotiateServiceCredential="false" />
</security>
</binding> </wsHttpBinding>

" Everything seems to works fine in my test environment, which has two domains like in production. Nevertheless in production environment I get an ugly error every time "A" calls "B" which is:


    System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: An error occurred when verifying security for the message.

Server stack trace:
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

首先我认为这是服务器之间时钟同步的问题,因为我可以通过将时钟更改为 10 分钟的差异来在测试环境中重现相同的异常。不幸的是,这似乎不是问题,因为我们的生产服务器是同步的。

任何信息将不胜感激!!

最佳答案

最终我们可以解决问题,因为缺少权限,应用程序池标识无法写入“C:\Windows\Temp”。

似乎 MessageSecurityException 是一种通用的异常,可以针对许多问题抛出。为了了解真正的异常,我们向服务配置添加了一个 serviceDebug 行为,并观察事件查看器以获取有关错误的详细信息。

这是调试配置:


<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceSecurityAudit auditLogLocation="Application"
suppressAuditFailure="false"
serviceAuthorizationAuditLevel="None"
messageAuthenticationAuditLevel="SuccessOrFailure" />
</behavior>


谢谢!

关于asp.net - 在 DMZ 中运行安全 WCF 服务时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1901639/

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