我可以通过Internet访问WCF服务,该服务使用带有消息安全模式和用户名客户端凭据的wsHttpBinding。
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding" messageEncoding="Mtom" maxReceivedMessageSize="104857600">
<readerQuotas maxArrayLength="104857600"/>
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
我发现将数据从客户端传输到服务器需要花费太多时间。 我已经读过,我可以使用customBinding和binaryEncoding模式进行我的服务。
就像那样:
<bindings>
<customBindings>
<binding name="NetHttpBinding">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBindings>
<bindings>
但是这里没有提及消息安全模式和客户端凭证类型......
我如何使用带有binaryEncoding的自定义绑定并使用用户名客户端凭据保持消息安全模式?
答案 0 :(得分:2)
我知道这不是您要找的答案,但这是我的配置。
我使用UserNameOverTransport
身份验证的自定义绑定。
它可能会为您提供一些线索,让您知道如何改变以获得您的信息。运行
<customBinding>
<binding name="MyCustomHttpBinding" receiveTimeout="00:20:00" sendTimeout="00:20:00">
<security authenticationMode="UserNameOverTransport">
<localServiceSettings maxClockSkew="Infinite" />
</security>
<mtomMessageEncoding maxBufferSize="2097152" messageVersion="Soap12" >
<readerQuotas maxStringContentLength="2097152"/>
</mtomMessageEncoding>
<httpsTransport maxBufferSize="2097152" maxReceivedMessageSize="1073741824" transferMode="Streamed" />
</binding>
</customBinding>
请记住,我使用MTOM编码,在我的情况下,它更适合我的场景。
答案 1 :(得分:1)
将secureConversation Bootstrap设置为已协商的UserNameForSs。尝试类似于下面绑定的内容。
<bindings>
<customBinding>
<binding name="wss-username-binary">
<transactionFlow/>
<security
authenticationMode="SecureConversation"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap
authenticationMode="UserNameForSslNegotiated"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
</security>
<binaryMessageEncoding />
<httpTransport/>
</binding>
</customBinding>
</bindings>
答案 2 :(得分:-1)
尝试此操作可能会对您有所帮助----它具有自定义绑定,自定义安全性和证书。
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="CommonBinding" maxReceivedMessageSize ="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Custom.Security.CustomUserNameValidator, Custom.Security" />
<clientCertificate>
<authentication certificateValidationMode= "PeerOrChainTrust" />
</clientCertificate>
<serviceCertificate findValue="CertName" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="True"/>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="Custom.Security.AuthorizationPolicy, Custom.Security" />
</authorizationPolicies>
</serviceAuthorization>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>