【发布时间】:2014-05-21 13:03:53
【问题描述】:
我遇到了 BizTalk Server 2013 和 WCF 服务的问题。 BizTalk 需要使用 WCF 服务。 BizTalk 需要使用 X509 证书对消息进行签名,我收到以下错误消息:
There was a failure executing the send pipeline: "BizTalkUtilities.SignPipeline,
BizTalkUtilities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d749e81ab815db56" Source:
"MIME/SMIME encoder" Send Port: "SndPort_Sign_V2" URI: "http://XXXX/DemoServiceSigned
/DemoService.svc" Reason: The message has a bad message signature.
首先我创建了没有安全性的服务,一切正常。一旦我设置了我的安全性(消息安全性,签名),它就不再起作用了。为了确保我的服务正常,我创建了一个测试 WCF 客户端,它使用安全的服务 - 没问题。
消息需要使用 X509 证书进行签名。所有证书都在正确的位置。我按照MSDN 上的信息进行操作。
服务配置:
<bindings>
<wsHttpBinding>
<binding name="clientSignConfig">
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="SignServiceBL.DemoService" behaviorConfiguration="DemoServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="clientSignConfig"
contract="SignServiceBL.IDemoService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DemoServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine"/>
</clientCertificate>
<serviceCertificate findValue="CN=DemoServiceServerCertificate"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
客户端配置(这适用于 WCF 客户端,但不适用于 BizTalk)
<bindings>
<customBinding>
<binding name="demoService_CustomBinding">
<transactionFlow />
<security authenticationMode="SecureConversation" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap authenticationMode="MutualSslNegotiated" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
</security>
<textMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="signingBehavior">
<clientCredentials>
<clientCertificate findValue="CN=DemoServiceSigning"
storeLocation="CurrentUser" storeName="My"/>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://XXXX/DemoServiceSigned/DemoService.svc"
binding="customBinding" bindingConfiguration="demoService_CustomBinding" behaviorConfiguration="signingBehavior"
contract="DemoService.IDemoService" name="WSHttpBinding_IDemoService">
<identity>
<dns value="DemoServiceServerCertificate"/>
</identity>
</endpoint>
</client>
我已设置跟踪,但 BizTalk 甚至没有向我的服务发送消息。这就像 sendpipeline 阻止了我的请求。
有什么想法吗?
编辑
您不需要带有 MIME/SMIME 编码器的管道来签署 WCF 消息。如果你需要签署电子邮件,你应该使用这个管道......见MSDN的第一句话
BizTalk Server 支持对入站安全多用途 Internet 邮件扩展 (S/MIME) 消息进行签名出站消息和签名验证
删除管道后,BizTalk 会向服务发送一条消息。现在的问题是它已签名和加密。我正在弄清楚如何告诉 BizTalk 只签署消息。如果您有任何想法,请随时发布。如果我找到它,我会发布它;-)
【问题讨论】:
-
您的 MIME/SMIME 编码器有哪些设置?私钥证书是否在主机实例用户\个人存储中并在 BizTalk Server 组级别进行配置?
-
是的,我按照 MSDN 的完整示例。它应该可以工作。
-
您是否尝试过使用 HTTP 调试工具(例如 Fiddler)来检查从 BizTalk 和您的测试 WCF 客户端发出的有效负载?也许您可以从中发现一些差异并找出问题所在。
-
@您之前的评论:我需要签署 WCF 消息,而不是电子邮件消息,因此我不需要 MIME/SMIME 编码器。我删除了管道,现在 BizTalk 服务器对消息进行签名和加密。它应该只对消息进行签名,所以现在我试图通过使用自定义端点行为并修改客户端代理的保护级别来实现这一点。这真的是在 BizTalk 中签署 WCF 消息的方法吗?
-
其他人提出了相同(未回答)的问题,但使用的是动态发送端口stackoverflow.com/questions/16570047/…
标签: c# .net wcf biztalk x509certificate