Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ssl verify #19

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/logstash/plugin_mixins/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def setup_http_client_config

# Set this to false to disable SSL/TLS certificate validation
# Note: setting this to false is generally considered insecure!
config :ssl_certificate_validation, :validate => :boolean, :default => true
config :ssl_certificate_validation, :validate => :string, :default => 'strict'

# If you need to use a custom X.509 CA (.pem certs) specify the path to that here
config :cacert, :validate => :path
Expand Down Expand Up @@ -120,7 +120,17 @@ def client_config
@proxy
end

c[:ssl] = {}
# This is the first ssl hash value.
# must be one of "disable", "browser", "strict"
if defined?(@ssl_certificate_validation)
valid_values = ["disable", "browser", "strict"]
if valid_values.include?(@ssl_certificate_validation)
c[:ssl] = { :verify => @ssl_certificate_validation.to_sym }
else
raise InvalidHTTPConfigError, "Invalid value for 'ssl_certificate_validation', must be string with value of 'disable', 'browser', 'strict'."
end
end

if @cacert
c[:ssl][:ca_file] = @cacert
end
Expand Down