【问题标题】:There was and error downloading 'https://$metadata'. The request failed with http status 403: Forbidden - XAMARIN WEB REFERENCE WITH HTTPS下载“https://$metadata”时出错。请求失败,http 状态为 403:禁止 - XAMARIN WEB REFERENCE WITH HTTPS
【发布时间】:2017-10-23 06:26:11
【问题描述】:

我设法创建了一个带有自签名SSLIIS 的网络service。它的设置首先设置为客户端证书无和不需要SSL。到那时已经可以访问网络浏览器和移动网络参考了。

网络浏览器

Xamarin 网络参考

但是当我将 SSL 设置设置为必需时,现在两者都被禁止。 SSL 配置的设置中缺少什么?

通过 IIS 的 SSL 设置

Web 浏览器禁止访问

Xamarin Web 参考禁止访问

网络配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="constring" providerName="System.Data.SqlClient" connectionString="Data Source = source;Initial Catalog = dbname; User ID = user; Password = pw" />
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="10485760" name="SecureHttpBinding">
          <readerQuotas maxStringContentLength="10485760"></readerQuotas>
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </basicHttpBinding>    
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- 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" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

【问题讨论】:

  • 我没试过,但是你看到这部分了吗:Using Transport Security
  • 不,这是我第一次看到它并感谢它。请问我应该把这些代码放在哪里?
  • 试试这个教程:UsingTrustedRootsRespectfully.
  • 我已经找到了答案。感谢您的链接,但似乎这不是我正在寻找 xamarin.android 网络参考的答案

标签: web-services wcf ssl iis xamarin.android


【解决方案1】:

为了在网络浏览器中通过 HTTPS 访问网络服务,我遵循了this link for creating temporary client certificate,但我将第 5 步更改为该命令

makecert -sk MyKeyName -iv RootCaClientTest.pvk -n "CN=tempClientcert" -ic RootCaClientTest.cer -sr localmachine -ss my -sky exchange -pe

我将 currentuser 更改为 localmachine 并将 signature 更改为 exchange 以便它在个人证书存储中。当您再次访问该站点时,它会要求您提供客户端证书,您可以选择它继续。

主要问题是通过 Web 引用访问 Visual Studio xamarin 中的服务(以某种方式被禁止)。
我找到了this link to solve the forbidden problem。您可以查看 (c)MarkoOkram 的第二篇文章以获取解决方案。

“我通过在文件系统上保存 Web 浏览器 .wsdl 和 .xsd 文件解决了问题,将这些文件中的引用更改为匹配文件。然后我成功地在 Visual Studio 中将引用添加到该文件系统 .wsdl 文件。” -(c) MarkoOkram

我下载了用 WSDL 编写的文件 WSDL 和 XSD,然后将文件路径重新定位到它们各自的目录,就完成了。

更新:我也尝试导入 singleWSDL,它无需编辑 xsd 即可工作

【讨论】:

  • 但是有一个新问题。连接被拒绝:(。System.Net.WebException:错误:ConnectFailure(连接被拒绝)---> System.Net.Sockets.SocketException:连接被拒绝
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-29
  • 1970-01-01
  • 2015-06-29
  • 2018-07-10
  • 2016-05-11
  • 2020-10-15
相关资源
最近更新 更多