【问题标题】:help setting up wsHttpBinding WCF service on .net帮助在 .net 上设置 wsHttpBinding WCF 服务
【发布时间】:2011-02-15 00:13:56
【问题描述】:

我正在尝试使用 wsHttpBinding 托管 WCF 服务。我使用 makecert 创建了一个证书,并在 web.config 中放置了一些行。

这是我得到的错误:

System.ArgumentException: The certificate 'CN=WCfServer' must have a private key that is capable of key exchange. The process must have access rights for the private key.

在谷歌上搜索时,证书文件的访问权限似乎存在一些问题。我使用 cacls 授予 NETWORK SERVICE 和我的用户名的读取权限,但它没有改变任何内容。

我还进入了证书文件属性中的安全设置,并完全控制了 NETWORK SERVICE 和我的用户名。再次无济于事。

您能否指导我解决问题以及我需要做什么?我对这些证书的东西真的很不满意。

这是我的 web.config:

<system.serviceModel>

<services>
        <service name="Abc.Service" behaviorConfiguration="Abc.ServiceBehavior">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Abc.BindConfig" contract="Abc.IService">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>

<behaviors>
    <serviceBehaviors>
        <behavior name="Abc.ServiceBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>

            <serviceCredentials>
                <clientCertificate>
                  <authentication certificateValidationMode="PeerTrust"/>
                </clientCertificate>
                <serviceCertificate findValue="WCfServer" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
            </serviceCredentials>

        </behavior>
    </serviceBehaviors>
</behaviors>

<bindings>
  <wsHttpBinding>
    <binding name="Abc.BindConfig">
      <security mode="Message">
        <message clientCredentialType="Certificate" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

</system.serviceModel>

【问题讨论】:

    标签: .net wcf web-services certificate wshttpbinding


    【解决方案1】:

    从我从网上收集到的信息来看,这似乎不是权限问题,更像是证书配置有问题。

    Here 有关于如何允许访问私钥的说明。

    您是否安装并运行了 IIS7。那里有一个 very simple tool 用于创建我已成功用于 WCF 通信的证书(而不是 makecert)。

    【讨论】:

      【解决方案2】:

      看看Windows HTTP Services Certificate Configuration Tool (WinHttpCertCfg.exe)。它允许向 Windows 帐户授予对 X.509 证书私钥的访问权限。

      Here is a blog post 解释了如何使用该工具。

      【讨论】:

        【解决方案3】:

        好的.. 我知道问题出在哪里。使用 makecert 创建证书时,必须使用 -pe 选项,这使得生成的私有可导出,以便可以在证书中使用。问题是与 vs2008 捆绑的 makecert 版本是 5.131,它没有 -pe 选项。我在 microsoft sdk 6 中找到了 6.0 版,它有这个选项。

        这是我作为 .net 初学者发现的最大问题。同一个东西有很多不兼容的版本,当你在互联网上查找东西时,你不知道有人在谈论哪个版本。

        【讨论】:

          猜你喜欢
          • 2017-04-03
          • 1970-01-01
          • 2018-10-08
          • 1970-01-01
          • 2011-05-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-07-31
          相关资源
          最近更新 更多