The issue of RemoteCertificateNameMismatch in .Net 6 when calling AWS GetObjectAsync can be resolved by either ignoring the certificate validation or by updating the root certificates.
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
var client = new AmazonS3Client();
You can use the following code to update the root certificates:
// initialize HttpClientHandler instance with the default .NET implementation of SSL/TLS
var httpClientHandler = new HttpClientHandler();
// Enable automatic updates of root CA certificates
httpClientHandler.UseDefaultCredentials = true;
httpClientHandler.CheckCertificateRevocationList = true;
httpClientHandler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) =>
{
// validate cert with your own logic
return cert.Subject.Contains("domain.com");
};
var httpClient = new HttpClient(httpClientHandler);
var s3Client = new AmazonS3Client(httpClient);
Once the root certificates are updated, you should not face the RemoteCertificateNameMismatch issue when calling AWS GetObjectAsync.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-26 11:00:00 +0000
Seen: 11 times
Last updated: Nov 28 '22
What are the Cordapp Certificates used for in terms of signing and interacting?
How can SSL be used with CqlSessionFactoryBean in Springboot Cassandra?
How do I resolve a 502 error when attempting to call an HTTPS REST API from an HTTP REST API?
How can SSM parameters be accessed across multiple accounts?
How can compile-time errors be used to limit the possible permutations of a struct in Rust?
How can the SSL certificate verify error in Python be expressed differently?
What steps can I take to resolve the issue caused by GitHub's certificate/key change?
What causes my Rust program to perform differently based on the specific optimization level used?