'Serilog's Splunk Sink (installed from NuGet) shows SSL connection could not be established error

I created a .NET core 3.1 console application. Installed Serilog and Serilog's Splunk sink packages. My coding is as below:

Log.Logger = new LoggerConfiguration()
                    .MinimumLevel.Verbose()
                    .WriteTo.Console()
                    .WriteTo.File("logs/myapp.txt", rollingInterval: RollingInterval.Day)
                    .WriteTo.EventCollector("Host/services/collector", "Token", source: Environment.MachineName, sourceType: "mySourceType", host: "myHost", index: "my_index")
                    .CreateLogger();

I see below error when I send logs:

2022-02-24T08:44:40.6160913Z Exception while emitting periodic batch from Serilog.Sinks.Splunk.EventCollectorSink:

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

Is there a way to disable certificate validation while using NuGet packages as suggested in other queries?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source