1 year ago

#384190

test-img

Mehran Hafizi

Serilog.Sink.Elasticsearch, Could not create SSL/TLS secure channel

I am using Serilog and Serilog.Sink.Elasticsearch in an ASP web API project, there is an issue with the connection to the ELK service that has been configured on an azure Kubernetes cluster, I get the error below when I deploy my code on the windows server 2012 R2, but it works on my desktop correctly, and SSL has been issued by LetsEncrypt and expiration time is fine

packages:

  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
  <package id="Serilog" version="2.10.0" targetFramework="net472" />
  <package id="Elasticsearch.Net" version="7.17.0" targetFramework="net472" />
  <package id="Serilog.Sinks.Elasticsearch" version="8.4.1" targetFramework="net472" />

error:

2022-04-06T11:49:33.7509141Z Caught exception while preforming bulk operation to Elasticsearch: Elasticsearch.Net.ElasticsearchClientException: The request was aborted: Could not create SSL/TLS secure channel.. Call: Status code unknown from: POST /_bulk ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Elasticsearch.Net.HttpWebRequestConnection.d__5`1.MoveNext()

--- End of inner exception stack trace ---

at Elasticsearch.Net.Transport`1.HandleElasticsearchClientException(RequestData data, Exception clientException, IElasticsearchResponse response)

at Elasticsearch.Net.Transport1.FinalizeResponse[TResponse](RequestData requestData, IRequestPipeline pipeline, List1 seenExceptions, TResponse response)

at Elasticsearch.Net.Transport1.<RequestAsync>d__151.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Serilog.Sinks.Elasticsearch.ElasticsearchSink.d__2.MoveNext()

I've added these lines to Application_Start but it doesn't work me:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
            ServicePointManager.Expect100Continue = true;

Any thoughts?

c#

elasticsearch

asp.net-web-api2

serilog

windows-server-2012-r2

0 Answers

Your Answer

Accepted video resources