【问题标题】:WCF: set CustomBinding to Transport Only Security in codeWCF:在代码中将 CustomBinding 设置为仅传输安全性
【发布时间】:2019-09-06 09:00:38
【问题描述】:

我们在项目中使用了customBinding,我想在代码中设置Transport Only Security,应该相当于XML如下:

<security mode="Transport" />

我搜索了很多,但我找不到怎么做,因为我的 CustomBinding 类扩展了 System.ServiceModel.Channels.Binding 所以没有字段安全性。

我也在寻找下面 xml 的等效代码:

<message algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
         clientCredentialType="Certificate/IssuedToken/None/UserName/Windows"
         establishSecurityContext="Boolean"
         negotiateServiceCredential="Boolean" />

【问题讨论】:

    标签: c# wcf wcf-security


    【解决方案1】:

    例如你需要使用httpsTransport

    <httpsTransport authenticationScheme="Basic"  manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
    

    更多信息check

    【讨论】:

      【解决方案2】:

      对于自定义绑定中的传输安全模式,我们通常使用 HttpsTransport 部分进行配置。
      对于消息安全,由安全部分实现。
      请参考以下配置。

      <customBinding>
              <binding name="wss-username-binary">
                <transactionFlow/>
                <security
            authenticationMode="SecureConversation"
            messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
                  <secureConversationBootstrap
            authenticationMode="UserNameForSslNegotiated"
            messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
                </security>
                <binaryMessageEncoding />
                <httpsTransport/>
              </binding>
            </customBinding>
      

      WCF中的认证方式请参考以下文档。
      https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/securitybindingelement-authentication-modes
      如果有什么我可以帮忙的,请随时告诉我。

      已更新。

       //Under the WCF service created by the below binding, server provides a certificate to ensure the message security, and the client provides a username/password to represent an identity
              var b = SecurityBindingElement.CreateUserNameForCertificateBindingElement();
              TextMessageEncodingBindingElement encoding = new TextMessageEncodingBindingElement();
              HttpsTransportBindingElement transport = new HttpsTransportBindingElement();
              CustomBinding binding = new CustomBinding(b, encoding, transport);
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 2012-11-14
      • 2011-09-24
      • 1970-01-01
      • 2013-06-25
      • 2011-11-05
      相关资源
      最近更新 更多