【问题标题】:REST WCF Service hosting(https) in Windows Service on Win2003Win2003 上 Windows 服务中的 REST WCF 服务托管(https)
【发布时间】:2011-06-24 04:18:31
【问题描述】:

我在 Windows 服务中自行托管 REST WCF 服务。该服务公开了一个返回布尔值的方法,我能够让 REST Web 服务在 WinXp 上工作。我还使用makecert 生成了一个开发证书,并将其分配给服务侦听的端口(1443)。 Https 也适用于 WinXp。但是当我在Win2003中使用相同的,并在IE中输入URL时,它说“页面无法显示”。托管服务没有错误,服务在端口上侦听(ServiceHost.Open 没有任何错误并且成功)。在Win2003中是否需要为此进行设置? Win2003 是生产环境,https 必须在上面工作。

这是我使用的配置文件,

 <system.serviceModel>
<bindings>
  <webHttpBinding>
    <binding name="httpBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="spectrumServiceBehavior" name="MyApp.TestService">
    <host>
      <baseAddresses>
        <add baseAddress="https://localhost:1443/" />
      </baseAddresses>
    </host>
    <endpoint address=""
              binding="webHttpBinding"
              bindingConfiguration ="httpBinding"
              contract="MyApp.ITestService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="spectrumServiceBehavior">
      <!-- To receive exception details in faults for debugging purposes, 
        set the value below to true.  Set to false before deployment 
        to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpsGetEnabled ="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

有什么想法吗?

【问题讨论】:

    标签: wcf rest https


    【解决方案1】:

    我也遇到过同样的问题。使用 HTTPS 的 WinXP 开发环境,在本地创建证书并使用 httpcfg 分配给自定义端口。 Windows 2003 上的生产环境,使用导入的证书和相同的 httpcfg 配置在尝试获取服务的 WSDL 时给出“中断连接”。

    查看Windows日志我终于发现了这个错误:

    事件来源:Schannel

    尝试访问 SSL 服务器凭据私钥时发生致命错误。从加密模块返回的错误代码是 0x80090016。

    我的问题是我在用户帐户存储中导入了证书,然后在本地存储中复制。这样,私钥就被留下了......http://support.microsoft.com/kb/939616(甚至没有警告!!!) 尽管如此,在新位置打开证书,显示存在私钥!

    【讨论】:

      【解决方案2】:

      我希望在 Windows 2003 上您必须允许应用程序侦听端口(除非它以管理员身份运行)并且您必须为端口分配 SSL 证书 - 两者都由 httpcfg.exe 执行。还要检查是否有防火墙阻止端口上的通信。

      【讨论】:

      • 我确实在 WinXp 和 Win2003 中都使用了 httpcfg.exe。 SSL 证书已分配给端口,应用程序正在侦听端口,并且我正在使用管理员帐户运行。我在同一台 Win2003 机器上尝试了 URL,但 IE 仍然报错说页面无法显示。
      • 我还检查了防火墙,它没有在那台机器上运行。 ICS 服务没有运行,因此防火墙也没有运行。
      • 我也遇到了同样的问题,我在 WindowsXP 上一切正常,但在 Windows 2003 R2 上什么也没有。在 Microsoft 文档/论坛/问答中环顾四周,它总是相同的东西......写在这里希望听到你解决你的问题。提前 Tnx。
      • @Fabio:您是否使用 netsh.exe 设置 URL ACL 和 SSL 证书分配?
      • @LadislavMrnka 不,在 Win2003 httpcfg.exe 上
      猜你喜欢
      • 1970-01-01
      • 2014-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-06
      • 2012-04-28
      相关资源
      最近更新 更多