【问题标题】:Securing WCF with basichttpbinding使用 basichttpbinding 保护 WCF
【发布时间】:2013-08-27 14:48:17
【问题描述】:

我在我的 WCF 服务(.Net Framework 4.0)中使用 basicHttpBinding、消息安全和 x509 证书。配置如下所示:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
            <serviceCertificate findValue="MyWebSite" storeLocation="LocalMachine"
             storeName="My" x509FindType="FindBySubjectName" />
            <userNameAuthentication userNamePasswordValidationMode="Custom"
             customUserNamePasswordValidatorType="CToSave.ValidateClient, CToSave" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

    <standardEndpoints>
      <webScriptEndpoint>
        <standardEndpoint crossDomainScriptAccessEnabled="True"/>
      </webScriptEndpoint>
    </standardEndpoints>

    <services>
      <service behaviorConfiguration="ServiceBehavior" name="CToSave.MyService">
        <endpoint address="" binding="basicHttpBinding" contract="CToSave.IMyService" bindingConfiguration="BindingConfig"/>
      </service>
    </services>

    <bindings>

      <basicHttpBinding>
        <binding name="BindingConfig" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" closeTimeout="00:50:00" maxReceivedMessageSize="2147483647">
          <security mode="Message">
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </basicHttpBinding>

    </bindings>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>


</configuration>

PHP 客户端将使用此服务。为了消费它,客户端是否需要证书?我希望客户端不必生成证书。

如果客户端必须获得证书,我的配置会改变吗?如果是,我需要做出哪些改变?

我已经阅读了数十篇关于 basihttpbinding+security 的文章,但没有一篇文章表明有关客户端证书的任何内容。请帮忙。

【问题讨论】:

    标签: wcf wcf-security x509certificate basichttpbinding


    【解决方案1】:

    是的,客户因此需要证书:

    <security mode="Message">
        <message clientCredentialType="Certificate"/>
    </security>
    

    一般而言,客户不会生成自己的证书,而是从同意的提供者(可以是组织中的证书颁发机构或公共机构或服务所有者)处获取。

    在任何情况下,您都需要一个好的 PHP WS-Security 库,因为您需要生成 WCF 期望的消息格式(这是消息级别的安全性)。

    【讨论】:

    • 您能否详细说明“一般客户端不会生成自己的证书,而是从同意的提供者那里获取(可以是组织中的证书颁发机构或公共机构或服务所有者)。”??我应该使用什么“clientcredentialtype”以便客户端不需要证书?
    • 这取决于您希望如何向服务器验证客户端。可以是无,用户名...取决于你的需要
    • 服务将通过客户端发送的用户名和密码对客户端进行身份验证。我正在使用覆盖System.IdentityModel.Selectors.UserNamePasswordValidator 中的Validate 函数进行身份验证。在服务中根据用户名和身份验证客户端密码。在这种情况下,我应该使用哪个clientcredentialtype
    • clientCredentialType=UserName
    • 我相信代理需要卸载 ssl 并将普通的 http 发送到 iis,就像一些 xml 网关一样。自己没有做过。无论如何,这个错误令人惊讶,基本的 http 应该允许你配置你想要的任何安全性(这就是这个设置的目的),除非你配置了一些额外的层来以某种方式阻止它。
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-03
      相关资源
      最近更新 更多