splunk / splunk-sdk-ruby

Splunk Software Development Kit for Ruby
http://dev.splunk.com
Apache License 2.0
36 stars 21 forks source link

Cannot specify SSL verify_mode or CA chain #47

Open matthewdooler opened 8 years ago

matthewdooler commented 8 years ago

I'm having trouble connecting to an SSL-cert-protected Splunk instance because there is no way to set the SSL verify_mode to VERIFY_PEER and pass in a CA chain. I can set my cert and key but since there is no way to pass the full CA chain which contains the required intermediate certs, then authentication fails.

The root of the problem is that the verify mode is currently hard-coded to VERIFY_NONE in lib/splunk-sdk-ruby/context.rb. This seems to be analogous to the --insecure curl flag, which doesn't just ignore the server cert but also breaks authentication when intermediate certs need to be passed in.

A potential fix to the splunk sdk would be to allow verify_mode and the path to the CA chain to be passed in, which would then be set inside context.rb (the verify_mode and ca_file attributes on Net::HTTP and ssl_context.verify_mode). I can provide a full example if that would help.

Is it likely that this could be fixed? I really can't think of a way of working around this without actually changing the sdk.

Version of project: 1.0.5 Platform version: Mac OS X and Linux Framework version: Ruby 2.2.0 Splunk version: Splunk 6.1.3

itay commented 8 years ago

@MatthewDooler thanks for the bug report. A couple of things:

  1. Do you think it would be possible to get an example, as you suggested? Basically, the config on the Splunk side (with the relevant certs) and then the config and certs on the SDK side? That way it should be a lot easier to see what the fix should be.
  2. As always, we're open to Pull Request contributions to fix the issue :)
matthewdooler commented 8 years ago

I don't have admin access to the Splunk instance so can't pull down the exact config, but basically the setup is like this:

Does this help clear things up? If not, the fix should actually be quite easy so I can submit a PR if it's likely to be accepted!

imechemi commented 7 years ago

@matthewdooler Can I relate this https://gist.github.com/imechemi/785f839a1f162e52096f6b4216538a41 as well over here?