splunk / splunk-sdk-csharp-pcl

Splunk's next generation C# SDK
https://dev.splunk.com/enterprise/docs/csharp
Apache License 2.0
64 stars 46 forks source link

LogOnAsync("hostname", "password") is returning null response #72

Closed SaiSK88 closed 1 year ago

SaiSK88 commented 7 years ago

Hi All,

I am using Spluck C# SDK 2.2.5 with Visual Studio 2017. Below is the code,

Service service = new Service(Scheme.Https, "localhost", 8089); await service.LogOnAsync("admin", "adminone"); var searchResults = await service.SearchOneShotAsync("search index=_internal | head 10");

I am getting Null response for await service.LogOnAsync("username", "password") method.

The Splunk REST API is working fine. I verified it by running it through curl command, curl -k https://localhost:8089/services/auth/login -d username=admin -d password=adminone

I am able to get sessionKey using above curl command, however I am getting null response for LogOnAsync method.

Any suggestion on what could be missing here and how to fix it?

Thanks in advance.

Regards, Sai

tdhellmann commented 7 years ago

Hi Sai,

I assume this is on a development machine, right? You may be running into a certificate issue. In the examples that ship with the C# SDK, typically you will see this being done before connection:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };

Are you already using that workaround and still seeing this error? If so, can you also let me know what version of Splunk you're trying to connect to?

Best,

-Tedd

SaiSK88 commented 7 years ago

Hi Tedd,

Thanks for the quick reply.

I am using development machine, but I did not get any exception on Certificate Issue. Could you please let me know where do I need to put below code to check if it solves the issue,,

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };

I am using Splunk 6.4 which is running on the same machine.

Below is the code I am using,

namespace Splunk { class Program { public static async Task Connect() { Service service = new Service(Scheme.Https, "localhost", 8089);
await service.LogOnAsync("admin", "adminone"); var searchResults = await service.SearchOneShotAsync("search index=_internal | head 10"); return DateTime.Now; } static void Main(string[] args) {
Connect(); } } }

Regards, Sai

vicarrara commented 5 years ago

Hey Guys,

Any solution for this issue?

I have been same problem with my application.

Regards,

ncanumalla-splunk commented 1 year ago

This SDK is deprecated and no longer under active development.