This article is a mirror article of machine translation, please click here to jump to the original article.

View: 17919|Reply: 0

[WinForm] XmlDocument.Load(url) url is an SSL error when https is remote

[Copy link]
Posted on 6/21/2019 10:28:22 PM | | |
XmlDocument.Load(url) error "Underlying connection is closed: Failed to establish a trust relationship for the SSL/TLS secure channel." "According to the verification process, the remote certificate is invalid."

XmlDocument.Load(url) does not report an error when the url is a local file or http, but an error is reported when it is https remote. Basic connection is closed: Failed to establish a trust relationship for the SSL/TLS secure channel. "According to the verification process, the remote certificate is invalid."

The reason is that because there is no certificate, the certificate is invalid, and the workaround is as follows:

1. Add three references: using System.Net;     using System.Net.Security;      using System.Security.Cryptography.X509Certificates;

2. Add the following two methods, SetCertificatePolicy, and the RemoteCertificateValidate event


Using the above scheme does not work。。。。。


Tried the above code, but it didn't work。。。。。。。

Final Solution:

Upgrade the project to .NET 4.5.1 and right-click on the properties to modify. After the program starts, add the following code:

Resources:

Request aborted: Failed to create an SSL/TLS secure channel solution
https://www.itsvse.com/thread-7612-1-1.html
(Source: Architect_Programmer)








Previous:JS array operation summary
Next:IIS releases .NET 2.0 project with incorrect content formatting
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com