带有客户端证书的HttpWebRequest失败

时间:2019-01-30 09:53:00

标签: xamarin.ios

我正在使用Visual Studio Mac(最新版本),并且需要通过GET请求并通过客户端证书从IIs服务器(版本10)中获取数据。

不幸的是,IIs用RST数据包回答并显示错误:

The I/O operation has been aborted becourse of either a thread exit or an application request.

我知道苹果使用的是ATS(我使用的是iOS 10.3.3)。

我想这与客户端证书和IIS不接受它有关。

有人可以指向我一个不同的mono api,在那里我可以将客户端证书附加到GET请求吗?

到目前为止,我的代码如下(request.GetResponse()等到超时...):

X509Certificate2Collection certificates = new X509Certificate2Collection (certificate);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.uriString);
request.ClientCertificates = certificates;

request.Method = "GET";
request.ContentType = "application/json";
request.Accept = "application/json";
request.UserAgent = UserAgentString;
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version11;

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse ())
{
  this.webResponse = response;
  stream = response.GetResponseStream ();
}

0 个答案:

没有答案