BTS 2013 - 消息具有错误的消息签名

时间:2014-05-21 13:03:54

标签: c# .net wcf biztalk x509certificate

我遇到了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.  

首先,我创建了没有安全性的服务,一切正常。一旦我设置了我的安全性(消息安全性,Sign),它就不再起作用了。为了确保我的服务没问题,我创建了一个测试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只签署消息。如果您有任何想法,请随时发布。如果我找到它,我会发布它; - )

1 个答案:

答案 0 :(得分:1)

这并不容易,但我能够解决我的问题: - )

我写了一篇关于它的blogpost,因为在这里创建答案有点复杂。 所以看看吧!