【问题标题】:Webrequest not working on IIS8 with SSLWebrequest 不能在带有 SSL 的 IIS8 上工作
【发布时间】:2015-06-06 08:52:28
【问题描述】:

发送请求的代码及其调用 https

request =(HttpWebRequest) WebRequest.Create(url);

request.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
request.Timeout = 5000;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36";
request.ProtocolVersion = HttpVersion.Version11;


public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
    return true;
}

这段代码在我的本地系统上运行良好,但是当我们在 IIS 上部署它时,它无法发送请求。

【问题讨论】:

  • 您是否遇到任何错误?
  • 不,我没有收到任何错误,我检查它无法从 IIS 发送请求,但请求正在本地系统上进行并得到适当的响应
  • 你将不得不给我们更多的代码来处理。链接 AcceptAllCertifications 代码,并将代码放入带有日志的 try/catch 块中,以调查问题的原因。
  • public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate 证书, System.Security.Cryptography.X509Certificates.X509Chain 链, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; } 此代码用于 AcceptAllCertifications
  • 编辑您的原始帖子,并将其包含在将来。这似乎不是问题。如果它不起作用,那么您应该在某个地方遇到异常,我会确保它被记录在某个地方。

标签: c# iis ssl


【解决方案1】:

问题已解决 问题在服务器上。更新 IIS 主机文件注释不必要的 IP

【讨论】:

    猜你喜欢
    • 2015-12-07
    • 1970-01-01
    • 2017-11-12
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 1970-01-01
    • 2014-09-21
    • 1970-01-01
    相关资源
    最近更新 更多