首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

HTTPS请求不成功,该怎么解决

2013-07-01 
HTTPS请求不成功自己给HttpWebRequest做了些包装,主要是跟其他服务器接口做交互,使用Https协议,封装的类可

HTTPS请求不成功
自己给HttpWebRequest做了些包装,主要是跟其他服务器接口做交互,使用Https协议,封装的类可以在本地正常运行,但是放到服务器上面之后就请求超时,并且同一个服务器上面的WinForm程序能够正常使用这个类,自己写了一个简单的页面做了下测试,本地也是可以正常运行的,服务器上就请求超时,代码如下
protected void Page_Load(object sender, EventArgs e)
    {

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
        HttpWebRequest reqs = (HttpWebRequest)HttpWebRequest.Create("https://123.123.....");

        string path= Server.MapPath("~/AppConfig/abc.pfx");

        X509Certificate cer = new X509Certificate(path, "123");
        reqs.ClientCertificates.Add(cer);
        HttpWebResponse resp = (HttpWebResponse)reqs.GetResponse();

        StreamReader streamReader = new StreamReader(resp.GetResponseStream());
        string str = string.Empty;
        str = streamReader.ReadToEnd();
        Response.Write(str);
    }

    public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    {
        return true;
    }

这个是运行的异常
Server Error in '/' Application.
--------------------------------------------

The request was aborted: Could not create SSL/TLS secure channel. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[WebException: The request was aborted: Could not create SSL/TLS secure channel.]
   System.Net.HttpWebRequest.GetResponse() +5313085
   _Default.Page_Load(Object sender, EventArgs e) +215
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50


   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 
怀疑是IIS配置的问题,在网上找了很多资料,都不行,有没有遇到过这个问题的,麻烦指点指点HTTPS请求不成功,该怎么解决
HTTPS请求不成功,该怎么解决

热点排行