serilog-sinks-elasticsearch icon indicating copy to clipboard operation
serilog-sinks-elasticsearch copied to clipboard

Elastricsearch with self signed certificates SSL

Open YassineHk opened this issue 3 years ago • 2 comments

Does this issue relate to a new feature or an existing bug?

  • [X] Bug
  • [ ] New Feature

What version of Serilog.Sinks.Elasticsearch is affected? Please list the related NuGet package. latest

What is the target framework and operating system? See target frameworks & net standard matrix.

  • [X] netCore 2.0
  • [ ] netCore 1.0
  • [ ] 4.7
  • [ ] 4.6.x
  • [ ] 4.5.x

the current behavior I want to pass an SSL certificate generated by myself from my dotnet app to my certificate elasticsearch

the expected behavior `

          var elasticUri = Configuration["ElasticConfiguration:Uri"];
          StreamWriter writer = File.CreateText("serilog.log");
          SelfLog.Enable(writer); 
          Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext()
          .MinimumLevel
          .Information() 
          .WriteTo.RollingFile("Logs/log-{Date}.log", LogEventLevel.Warning)
          .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(elasticUri)) 
          {
              IndexFormat = Configuration["ElasticConfiguration:Index"],
              AutoRegisterTemplate = true,
          })
          .CreateLogger(); 

`

@mivano

YassineHk avatar Mar 04 '21 09:03 YassineHk

You can use the following option:

            ModifyConnectionSettings = c => c
                .ConnectionLimit(-1)
                .ServerCertificateValidationCallback((o, certificate, arg3, arg4) => { return true; })

That will override the server certificate validation.

tobiasschittkowski avatar Jun 15 '21 16:06 tobiasschittkowski

You can use the following option:

            ModifyConnectionSettings = c => c
                .ConnectionLimit(-1)
                .ServerCertificateValidationCallback((o, certificate, arg3, arg4) => { return true; })

That will override the server certificate validation.

How can this be done in the appsettings.json?

davidnmbond avatar May 02 '22 14:05 davidnmbond