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

TLS client certificate #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 21 additions & 2 deletions lib/logstash/inputs/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,18 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
# SSL
config :ssl, :validate => :boolean, :default => false

# SSL verify certificate
config :ssl_verify, :validate => :boolean, :default => true

# SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary
config :ca_file, :validate => :path

# SSL Client Certificate file in PEM encoded format
config :client_cert_file, :validate => :path

# SSL Client Key file in PEM encoded format
config :client_key_file, :validate => :path

def register
require "elasticsearch"

Expand All @@ -140,8 +149,18 @@ def register
@hosts
end

if @ssl && @ca_file
transport_options[:ssl] = { :ca_file => @ca_file }
if @ssl
transport_options[:ssl] = {:verify => @ssl_verify}

if @ca_file
transport_options[:ssl][:ca_file] = @ca_file
end
if @client_cert_file
transport_options[:ssl][:client_cert] = OpenSSL::X509::Certificate.new(File.read(@client_cert_file))
end
if @client_key_file
transport_options[:ssl][:client_key] = OpenSSL::PKey::RSA.new(File.read(@client_key_file))
end
end

@client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options)
Expand Down