zoukankan      html  css  js  c++  java
  • System.Security.Authentication.AuthenticationException:根据验证过程,远程证书无效。

     好久没写博客了,今天突然遇到个神奇的问题。

    做好的网站在win10上和Windows sever 2012 上都没有问题,搬到Windows sever 2003上就出现了这么一个错误:

    Server Error in '/' Application.


    The remote certificate is invalid according to the validation procedure.

    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.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

    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: 

    [AuthenticationException: The remote certificate is invalid according to the validation procedure.]
       System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) +1752731
       System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +6079773
       System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
       System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +53
       System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +120
       System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +85
       System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +61
       System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
       System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +53
       System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +120
       System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +85
       System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +61
       System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
       System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +53
       System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +120
       System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +85
       System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +61
       System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
       System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +53
       System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +120
       System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +85
       System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +61
       System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
       System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +53
       System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +120
       System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +85
       System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +61
       System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +137
       System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) +143
       System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +99
       System.Net.TlsStream.CallProcessAuthentication(Object state) +47
       System.Threading.ExecutionContext.runTryCode(Object userData) +80
       System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
       System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) +105
       System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) +125
       System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +43
       System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +798
       System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +58
       System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) +26
       System.Net.ConnectStream.WriteHeaders(Boolean async) +139
    
    [WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.]
       System.Net.HttpWebRequest.GetResponse() +6038659
       Travel_Agency.server.WX_Enter.ProcessRequest(HttpContext context) +1044
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
    

    大概是:根据验证过程,远程证书无效。基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系  

    最后实在没辙,在一般处理程序进行请求前加了:

    ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
    不论证书是否有效,全部通过。暂时将问题解决
    这是在静态类型上的方法,所以只需要添加一次即可,不过同时,这是应用程序全局的证书处理,如果你希望在不同的地方进行不同证书处理的话,请注意。
  • 相关阅读:
    JavaScript 浮点数处理
    从输入URL到浏览器显示页面发生了什么
    hadoop 编译任意版本的eclipse 插件
    Stm32F103面向对象编程之GPIO
    flume 1.7 安装与使用
    HIVE分组排序问题
    MapReduce实现共同朋友问题
    hadoop项目实战--ETL--(三)实现mysql表到HIVE表的全量导入与增量导入
    hadoop项目实战--ETL--(二)实现自动向mysql中添加数据
    hadoop项目实战--ETL--(一)项目分析
  • 原文地址:https://www.cnblogs.com/1711643472qq/p/9753696.html
Copyright © 2011-2022 走看看