System.Security.Authentication.AuthenticationException: The remote certificate is not valid according to the verification process.

Source: Internet
Author: User
Tags stack trace

Haven't written a blog for a long time, today suddenly encountered a magical problem.

Good site on WIN10 and Windows Sever 2012 is not a problem, moved to Windows Sever 2003 on the emergence of such an error:

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. Review the stack trace for more information about the error and where it is 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 Sy Stem. Net.TlsStream.Write (byte[] buffer, Int32 offset, Int32 size) +58 System.Net.PooledStream.Write (byte[] buffer, Int32 offs ET, Int32 size) +26 System.Net.ConnectStream.WriteHeaders (Boolean async) +139[webexception:the underlying connection WA   s 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

Presumably: The remote certificate is not valid according to the verification process. The underlying connection has been closed: failed to establish a trust relationship for the SSL/TLS secure channel

At the end of the process, the general handler is requested to add:

Servicepointmanager.servercertificatevalidationcallback = (sender, certificate, chain, sslpolicyerrors) = true;
Regardless of whether the certificate is valid, all passes. Temporarily fix the problem
This is a method on a static type, so you only need to add it once, but at the same time, this is the application Global certificate processing, if you want to do different certificate processing in different places, please note.

System.Security.Authentication.AuthenticationException: The remote certificate is not valid according to the verification process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.