保持MEX结合不安全,同时确保HTTP绑定瓦特/ UsernamePasswordValidator?
-
10-07-2019 - |
题
我们正在使用UsernamePasswordValidator与证书一起安全地访问我们的WCF服务。
但是,我们使用的是自定义的授权策略是服务行为,没有终点的行为,所以它们适用于所有终端,包括MEX端点。我们希望能够去抢夺使用Visual Studio中的服务引用,而不必每次都注释掉的服务行为,但由于双方在墨西哥和wshttp端点固定,我们做“添加服务引用时出现错误..“
有没有解决这个办法吗?
解决方案
您使用相同的两个约束力?如果是这样,尝试2个独立的绑定 - 一个用于MEX端点与一个用于wshttp:
因此,对于服务 - 是这样的:
<wsHttpBinding><binding name="wsHttpBindingMessageUname">
<security mode="Message">
<message clientCredentialType="UserName" negotiateServiceCredential="true"
establishSecurityContext="false" />
</security></binding></wsHttpBinding>
和用于MEX端点(无安全性):
<customBinding><binding name="customMex">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"/></binding></customBinding>
服务终端将是这样的:
<endpoint address="" behaviorConfiguration="Server.Services.DefaultEndpointBehavior" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingMessageUname" name="DefaultHttp" contract="Server.Services.IMyService" listenUriMode="Explicit" />
<endpoint address="mex" binding="customBinding" contract="IMetadataExchange" name="" bindingConfiguration="customMex" listenUriMode="Explicit" />
通过这种设置,它不应用安全MEX所以试图更新服务引用时,你不应该得到那个消息。如果不是这样,也可以创建另一个安全绑定使用不同的凭证,即,客户端证书在机器上。
其他提示
我觉得从他还指出,他使用的服务行为,所以绑定配置不会有所作为,因为整个服务使用UserNamePassword验证的问题。
两件事情想到这里。
取出明确MEX结合和下服务行为添加
<serviceMetadata httpsGetEnabled="true" />
,或保留MEX结合,和使
<serviceMetadata httpGetEnabled="true" />
请求元数据时CustomUserNameValidator犯规得到执行, 因此,如果未启用httpsgetenabled上,和你有一个MEX上http绑定,你需要 httpGetenabled上至少
不隶属于 StackOverflow