本文介绍了在失败与HttpWebRequest的内部异常验证失败,因为远程方已关闭传输流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用C#,.NET 4.5,我想发出HttpWebRequest的通过Web请求的远程服务器上。请参阅下面的code。
我试图最受一些论坛上提出的解决方案,但我总是相同的错误结束。请参考下面的堆栈跟踪。
调用request.GetReponse()方法时,引发错误。
附加信息,基本上,我试图调用安装在远程服务器上的VMware的vCenter组件的reloadSslCertificate功能。目前,该错误仅发生在vCenter上5.5。它工作正常,在5.1及以下版本。
VAR URI =的String.Format(https://开头{0} / SOME_URL,服务器名);
VAR请求=(HttpWebRequest的)WebRequest.Create(URI);
request.KeepAlive = TRUE;
request.Accept =text / html的,是application / xhtml + xml的,应用/ XML; Q = 0.9 * / *; Q = 0.8;
request.Headers.Set(HTT prequestHeader.AcceptLanguage,EN-US,连接; Q = 0.8);
request.Credentials =凭证;
request.CookieContainer =的CookieContainer;
变种响应= request.GetResponse();
Thanks in advance.
解决方案
I just want to share that this issue has already been resolved.
I just modified the part of the code where I set the security protocol before issuing the web request.
From:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
To:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
As it turned out, vCenter 5.5 uses TLS as its SSL protocol in its configuration. I hope people may find this helpful when they encounter this same issue.
这篇关于在失败与HttpWebRequest的内部异常验证失败,因为远程方已关闭传输流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!