An error occurred while remotely requesting HTTPS content in. NET: The remote certificate is not valid according to the authentication process.

Source: Internet
Author: User

When accessing HTTPS content, sometimes you often see a certificate error (not in the operating system's certificate trust chain?). ) prompt, in the browser we can ignore the wrong certificate, continue to access the content of the Web page.

However, in a. NET program, it is up to the code to determine whether to ignore the wrong certificate.

Solution:

Before you arbitrarily access the program code for HTTPS content, set up a certificate handler with the following code:

Servicepointmanager.servercertificatevalidationcallback = (sender, cert, chain, error) ==    {  Returntrue;};

This is because it is a static type method, so only need to add once, but also note that this is the application of global certificate processing, if you want to do different certificate processing in different places, please note.

Here, for the sake of convenience, return true directly, representing acceptance of the certificate, whether right or wrong. If the scenario requires rigor, you should carefully determine if the certificate is correct, and then return the result.

An error occurred while remotely requesting HTTPS content in. NET: The remote certificate is not valid according to the authentication 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.