nest client Bypass ssl Certificate error in .netcore application

Viewed 2082
var uris = new[]
                {
                    new Uri("https://10.8.173.179:9200"),
                };

                var connectionPool = new SniffingConnectionPool(uris);
                var settings = new ConnectionConfiguration(connectionPool);
                settings.BasicAuthentication("elastic", "password");
                var lowlevelClient = new ElasticLowLevelClient(settings);
                var health = lowlevelClient.Cluster.Health<StringResponse>();

Getting below : System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

1 Answers

Take a look at the working with certificates documentation.

If you're using a self signed cert, you can use either the following on ConnectionSettings.ServerCertificateValidationCallback(...)

  1. CertificateValidations.AllowAll; to allow all certificates

  2. CertificateValidations.AuthorityIsRoot(cert) and pass it the Certificate Authority (CA) public key to validate that the certificate the server presents is generated with the CA

  3. CertificateValidations.AuthorityPartOfChain(cert) and pass it the certificate.

Related