Module: Fluent::KafkaPluginUtil::SSLSettings

Included in:
Fluent::Kafka2Output, Fluent::KafkaGroupInput, Fluent::KafkaInput, Fluent::KafkaOutput, Fluent::KafkaOutputBuffered
Defined in:
lib/fluent/plugin/kafka_plugin_util.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/fluent/plugin/kafka_plugin_util.rb', line 4

def self.included(klass)
  klass.instance_eval {
    # https://github.com/zendesk/ruby-kafka#encryption-and-authentication-using-ssl
    config_param :ssl_ca_cert, :array, :value_type => :string, :default => nil,
                 :desc => "a PEM encoded CA cert to use with and SSL connection."
    config_param :ssl_client_cert, :string, :default => nil,
                 :desc => "a PEM encoded client cert to use with and SSL connection. Must be used in combination with ssl_client_cert_key."
    config_param :ssl_client_cert_key, :string, :default => nil,
                 :desc => "a PEM encoded client cert key to use with and SSL connection. Must be used in combination with ssl_client_cert."
  }
end

Instance Method Details

#pickup_ssl_endpoint(node) ⇒ Object



26
27
28
29
30
# File 'lib/fluent/plugin/kafka_plugin_util.rb', line 26

def pickup_ssl_endpoint(node)
  ssl_endpoint = node['endpoints'].find {|e| e.start_with?('SSL')}
  raise 'no SSL endpoint found on Zookeeper' unless ssl_endpoint
  return [URI.parse(ssl_endpoint).host, URI.parse(ssl_endpoint).port].join(':')
end

#read_ssl_file(path) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/fluent/plugin/kafka_plugin_util.rb', line 16

def read_ssl_file(path)
  return nil if path.nil?

  if path.is_a?(Array)
    path.map { |fp| File.read(fp) }
  else
    File.read(path)
  end
end