Module: Fluent::Plugin::ElasticsearchTLS

Included in:
ElasticsearchOutput
Defined in:
lib/fluent/plugin/elasticsearch_tls.rb

Defined Under Namespace

Modules: ElasticsearchTLSParams

Constant Summary collapse

SUPPORTED_TLS_VERSIONS =
if defined?(OpenSSL::SSL::TLS1_3_VERSION)
  [:TLSv1, :TLSv1_1, :TLSv1_2, :TLSv1_3].freeze
else
  [:SSLv23, :TLSv1, :TLSv1_1, :TLSv1_2].freeze
end
DEFAULT_VERSION =
:TLSv1_2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



43
44
45
# File 'lib/fluent/plugin/elasticsearch_tls.rb', line 43

def self.included(mod)
  mod.include ElasticsearchTLSParams
end

Instance Method Details

#set_tls_minmax_version_config(ssl_version, ssl_max_version, ssl_min_version) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fluent/plugin/elasticsearch_tls.rb', line 47

def set_tls_minmax_version_config(ssl_version, ssl_max_version, ssl_min_version)
  if USE_TLS_MINMAX_VERSION
    case
    when ssl_min_version.nil? && ssl_max_version.nil?
      ssl_min_version = METHODS_MAP[:TLSv1_2]
      ssl_max_version = METHODS_MAP[:TLSv1_3]
    when ssl_min_version && ssl_max_version.nil?
      raise Fluent::ConfigError, "When you set 'ssl_min_version', must set 'ssl_max_version' together."
    when ssl_min_version.nil? && ssl_max_version
      raise Fluent::ConfigError, "When you set 'ssl_max_version', must set 'ssl_min_version' together."
    else
      ssl_min_version = METHODS_MAP[ssl_min_version]
      ssl_max_version = METHODS_MAP[ssl_max_version]
    end

    {max_version: ssl_max_version, min_version: ssl_min_version}
  else
    log.warn "'ssl_min_version' does not have any effect in this environment. Use 'ssl_version' instead." unless ssl_min_version.nil?
    log.warn "'ssl_max_version' does not have any effect in this environment. Use 'ssl_version' instead." unless ssl_max_version.nil?
    {version: ssl_version}
  end
end