Hi @Anh Khoa Nguyen , Welcome to Microsoft Q&A,
The error you're encountering indicates that the SSL handshake between your server and the Elasticsearch domain failed due to an unexpected or malformed message, which typically indicates an issue with TLS compatibility or SSL certificate configuration.
Make sure both the server and Elasticsearch are using compatible TLS versions. By default, .NET Core 3.1 and later (including .NET 6) use TLS 1.2 or 1.3. However, older servers might still attempt to use outdated protocols such as TLS 1.0 or 1.1. To force the use of TLS 1.2/1.3, you can explicitly configure it in your code:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
Although you mentioned that the SSL certificate is valid, you should ensure that:
- The full certificate chain, including any intermediate certificates, is correctly installed.
- The server trusts the root certificate authority (CA) used by Elasticsearch. If the certificate is self-signed or issued by an internal CA, ensure that it is installed in the server's trust store.
If you suspect the problem is with SSL certificate validation, you can temporarily disable SSL validation to verify this:
var connectionSettings = new ConnectionSettings(new Uri("https://xxx.xxx.com")) .ServerCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => true);
var elasticClient = new ElasticClient(connectionSettings);
This should only be used for debugging purposes. If this resolves the issue, then there is an SSL certificate or chain issue.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.