<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: NetCore 2.1 - how to handle &amp;quot;Invalid Certificate&amp;quot; issue in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/579027#M6254</link>
    <description>&lt;P&gt;Should probably consider using HttpClient instead WinHttp.&lt;/P&gt;&lt;P&gt;var handler = new HttpClientHandler&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ServerCertificateCustomValidationCallback =&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (sender, cert, chain, sslPolicyErrors) =&amp;gt; { return true; }&lt;BR /&gt;};&lt;/P&gt;</description>
    <pubDate>Tue, 21 Dec 2021 14:54:40 GMT</pubDate>
    <dc:creator>ThisNoName</dc:creator>
    <dc:date>2021-12-21T14:54:40Z</dc:date>
    <item>
      <title>NetCore 2.1 - how to handle "Invalid Certificate" issue?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/378233#M6252</link>
      <description>&lt;P&gt;Using latest NetCore Splunk.Client,&lt;/P&gt;
&lt;P&gt;The following fails&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;   ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) =&amp;gt;
        {
            return true;
        };
        Service service = new Service(new Uri(SplunkBaseUri));
        var task = service.LogOnAsync("Jas", "1234");
        task.Wait();
        return service;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With&lt;BR /&gt;* AuthenticationException: The remote certificate is invalid according to the validation procedure.&lt;BR /&gt;* HttpRequestException: The SSL connection could not be established, see inner exception.&lt;/P&gt;
&lt;P&gt;If I write it using HttpClient, i.e.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;     HttpClient client = new HttpClient(new HttpClientHandler
                {
                    ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) =&amp;gt; true
                })
                {
                    BaseAddress = baseAddress
                };
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This does not happen. How do we do this with the new Splunk.client?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jan 2021 05:42:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/378233#M6252</guid>
      <dc:creator>klassesen</dc:creator>
      <dc:date>2021-01-23T05:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: NetCore 2.1 - how to handle "Invalid Certificate" issue</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/536896#M6253</link>
      <description>&lt;P&gt;For those who stumble onto this question from a search engine (like me), here is how I fixed this. .Net Core changed how ServicePointManager works, so instead of doing the override suggested in the Splunk docs, you need to provide a custom handler to the Context object. Like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) =&amp;gt; true;
var ctx = new Context(Scheme.Https, "your_splunk_enterprise_url", 8089, default, handler);
this._splunkService = new Service(ctx);
await this._splunkService.LogOnAsync("username", "password");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After doing this the LogOnAsync method no longer returns the error about invalid certificate validation procedure etc. My app is targeting .NET Core 3.1.&lt;/P&gt;&lt;P&gt;Mods - can we get this added to the official documentation, perhaps?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2021 20:55:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/536896#M6253</guid>
      <dc:creator>lettucemode</dc:creator>
      <dc:date>2021-01-22T20:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: NetCore 2.1 - how to handle "Invalid Certificate" issue</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/579027#M6254</link>
      <description>&lt;P&gt;Should probably consider using HttpClient instead WinHttp.&lt;/P&gt;&lt;P&gt;var handler = new HttpClientHandler&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ServerCertificateCustomValidationCallback =&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (sender, cert, chain, sslPolicyErrors) =&amp;gt; { return true; }&lt;BR /&gt;};&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 14:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/NetCore-2-1-how-to-handle-quot-Invalid-Certificate-quot-issue/m-p/579027#M6254</guid>
      <dc:creator>ThisNoName</dc:creator>
      <dc:date>2021-12-21T14:54:40Z</dc:date>
    </item>
  </channel>
</rss>

