# SSL connection issue while logging into elastic search server

**URL:** <https://discuss.elastic.co/t/ssl-connection-issue-while-logging-into-elastic-search-server/351641>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [January 23, 2024, 3:19pm UTC](https://discuss.elastic.co/t/ssl-connection-issue-while-logging-into-elastic-search-server/351641 "2024-01-23T15:19:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phani\_Sekhar\_Veesam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_sekhar_veesam/32/124424_2.png) [@Phani\_Sekhar\_Veesam](https://discuss.elastic.co/u/Phani_Sekhar_Veesam)\
**Post date:** [January 23, 2024, 3:19pm UTC](https://discuss.elastic.co/t/ssl-connection-issue-while-logging-into-elastic-search-server/351641/1 "2024-01-23T15:19:25Z")

</div>

We are trying post the logs in Elasticsearch, but getting the below error from .net core. please guide me how to solve this error.

using (var handler = new HttpClientHandler())  
{

```
                    handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;

                    X509Certificate2 certificate1 = new X509Certificate2(@"path/certifi.cer");

                    handler.ClientCertificates.Add(certificate1);

                    using (var client = new HttpClient(handler))
                    {
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                        jsonstr = JsonConvert.SerializeObject(cur);

                        var content = new StringContent(jsonstr, Encoding.UTF8, "application/json");

                        var response = await client.PostAsync(LogServer, content);

                        res = await response.Content.ReadAsStringAsync();
                        if (res != "OK")
                        {
                            throw new Exception("Send to log server failed: res:" + res);
                        }
                    }
                }

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 20, 2024, 3:20pm UTC](https://discuss.elastic.co/t/ssl-connection-issue-while-logging-into-elastic-search-server/351641/2 "2024-02-20T15:20:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
