无法从Windows Mobile设备通过HTTPS调用azurewebsites.net上托管的WCF服务



我以免费网站模式将WCF服务上载到Azure网站
现在,我可以在Windows Phone设备和模拟器中使用Internet Explorer连接到https://<mysite>.azurewebsites.net/MyService.svc上的服务,而无需任何有关证书的警告。

接下来,我创建了WindowsPhone项目,并使用上面的url向我的WCF服务添加了服务引用。

我的应用程序在模拟器中运行良好,但不能在Windows Phone设备上运行。调用服务方法时得到System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. -> System.ServiceModel.FaultException: An error occurred when verifying security for the message.

我知道Windows Phone设备上的自签名插入的问题。但是azurewebsites.net证书由Baltimore CyberTrust Root证书签署。它是Windows Phone OS 7.1的root用户http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg521150(v=vs.105).aspx#BKMK_VeriSignBusinessUnitedStates

是否可以从Windows Phone设备调用Azure免费网站托管的安全WCF服务?或者我需要购买自己的证书?

适用于WCF服务的MyWeb.config

<services>
  <service name="SmallService.Services.MyService" behaviorConfiguration="SecureServiceBehavior">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="SecureServiceBinding"
              contract="SmallService.Services.IMyService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="SecureServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="DefaultRoleProvider" />
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="DefaultMembershipProvider" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="SecureServiceBinding">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

多亏了这篇文章,问题得到了解决
显然,这部手机是一部全新的,刚刚开箱即用,时钟已经过时了。有趣的是,Windows自动时钟同步不起作用。

所以我可以在设备上设置正确的日期和时间后通过HTTPS调用WCF服务。此外,在手机上下载和安装后,我可以使用自签名证书(请参阅http://wp7certinstaller.codeplex.com/获取更多信息)。

最新更新