bruno-garcia / log4net.ElasticSearch

log4net appender to ElasticSearch
https://bruno-garcia.github.io/log4net.ElasticSearch/
Other
219 stars 92 forks source link

Error - Could not create SSL/TLS secure channel when using Azure Elastic-Search #137

Closed adamfarmer0 closed 1 year ago

adamfarmer0 commented 2 years ago

image

I am getting this error when trying to connect to azure elastic-search.

my config:

<log4net>
<appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch">
  <connectionString value="Scheme=https;User=*******;Pwd=********;Server=commercial-***-***.es.westeurope.azure.elastic-cloud.com;Index=logs-2022;Port=443;rolling=true;" />
</appender>
<root>
  <level value="ALL" />
  <appender-ref ref="ElasticSearchAppender" />
</root>
</log4net>

Can anyone tell me how can I fix this? It's probably some certificate issue, but I can't figure it out.

adamfarmer0 commented 2 years ago

I have fixed it by adding:

          ServicePointManager.Expect100Continue = true;
          ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

in Startup.cs, inside Configuration method. For anyone that gets this error, this is the solution.

bruno-garcia commented 1 year ago

Nice. thanks for sharing the fix @adamfarmer0