When I am trying consuming a Web Service with a URL HTTPS it is causing this error message:
[SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority.
I have already read a solution to accept this trust between my client program (C#) and the HTTPS address:
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };
So my question is why my client could not establish trust relationship for the SSL/TLS secure channel with authority? Does somebody know? Because it seems that this solution is not safe.
If you are using .NET core, you can set CertificateValidationMode = X509CertificateValidationMode.None
and RevocationMode nocheck
client.ClientCredentials.ServiceCertificate.SslCertificateAuthentication =
new X509ServiceCertificateAuthentication()
{
CertificateValidationMode = X509CertificateValidationMode.None,
RevocationMode = System.Security.Cryptography.X509Certificates.X509RevocationMode.NoCheck
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.