Skip to content

Commit 953def7

Browse files
committed
Deprecated and added new SSL settings
1 parent 4507240 commit 953def7

File tree

11 files changed

+333
-75
lines changed

11 files changed

+333
-75
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 11.14.0
2+
- Reviewed and deprecated SSL settings to comply with Logstash's naming convention [#1115](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1115)
3+
- Deprecated `ssl` in favor of `ssl_enabled`
4+
- Deprecated `cacert` in favor of `ssl_certificate_authorities`
5+
- Deprecated `keystore` in favor of `ssl_keystore_path`
6+
- Deprecated `keystore_password` in favor of `ssl_keystore_password`
7+
- Deprecated `truststore` in favor of `ssl_truststore_path`
8+
- Deprecated `truststore_password` in favor of `ssl_truststore_password`
9+
- Deprecated `ssl_certificate_verification` in favor of `ssl_verification_mode`
10+
111
## 11.13.1
212
- Avoid crash by ensuring ILM settings are injected in the correct location depending on the default (or custom) template format, template_api setting and ES version [#1102](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1102)
313

docs/index.asciidoc

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ This plugin supports the following configuration options plus the
307307
| <<plugins-{type}s-{plugin}-action>> |<<string,string>>|No
308308
| <<plugins-{type}s-{plugin}-api_key>> |<<password,password>>|No
309309
| <<plugins-{type}s-{plugin}-bulk_path>> |<<string,string>>|No
310-
| <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|No
310+
| <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|__Deprecated__
311311
| <<plugins-{type}s-{plugin}-ca_trusted_fingerprint>> |<<string,string>>|No
312312
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
313313
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
@@ -333,8 +333,8 @@ This plugin supports the following configuration options plus the
333333
| <<plugins-{type}s-{plugin}-ilm_policy>> |<<string,string>>|No
334334
| <<plugins-{type}s-{plugin}-ilm_rollover_alias>> |<<string,string>>|No
335335
| <<plugins-{type}s-{plugin}-index>> |<<string,string>>|No
336-
| <<plugins-{type}s-{plugin}-keystore>> |a valid filesystem path|No
337-
| <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|No
336+
| <<plugins-{type}s-{plugin}-keystore>> |a valid filesystem path|__Deprecated__
337+
| <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|__Deprecated__
338338
| <<plugins-{type}s-{plugin}-silence_errors_in_log>> |<<array,array>>|No
339339
| <<plugins-{type}s-{plugin}-manage_template>> |<<boolean,boolean>>|No
340340
| <<plugins-{type}s-{plugin}-parameters>> |<<hash,hash>>|No
@@ -358,16 +358,23 @@ This plugin supports the following configuration options plus the
358358
| <<plugins-{type}s-{plugin}-sniffing>> |<<boolean,boolean>>|No
359359
| <<plugins-{type}s-{plugin}-sniffing_delay>> |<<number,number>>|No
360360
| <<plugins-{type}s-{plugin}-sniffing_path>> |<<string,string>>|No
361-
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|No
362-
| <<plugins-{type}s-{plugin}-ssl_certificate_verification>> |<<boolean,boolean>>|No
361+
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|__Deprecated__
362+
| <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> |list of <<path,path>>|No
363+
| <<plugins-{type}s-{plugin}-ssl_certificate_verification>> |<<boolean,boolean>>|__Deprecated__
364+
| <<plugins-{type}s-{plugin}-ssl_enabled>> |<<boolean,boolean>>|No
365+
| <<plugins-{type}s-{plugin}-ssl_keystore_password>> |<<password,password>>|No
366+
| <<plugins-{type}s-{plugin}-ssl_keystore_path>> |<<path,path>>|No
363367
| <<plugins-{type}s-{plugin}-ssl_supported_protocols>> |<<string,string>>|No
368+
| <<plugins-{type}s-{plugin}-ssl_truststore_password>> |<<password,password>>|No
369+
| <<plugins-{type}s-{plugin}-ssl_truststore_path>> |<<path,path>>|No
370+
| <<plugins-{type}s-{plugin}-ssl_verification_mode>> |<<string,string>>, one of `["full", "none"]`|No
364371
| <<plugins-{type}s-{plugin}-template>> |a valid filesystem path|No
365372
| <<plugins-{type}s-{plugin}-template_api>> |<<string,string>>, one of `["auto", "legacy", "composable"]`|No
366373
| <<plugins-{type}s-{plugin}-template_name>> |<<string,string>>|No
367374
| <<plugins-{type}s-{plugin}-template_overwrite>> |<<boolean,boolean>>|No
368375
| <<plugins-{type}s-{plugin}-timeout>> |<<number,number>>|No
369-
| <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|No
370-
| <<plugins-{type}s-{plugin}-truststore_password>> |<<password,password>>|No
376+
| <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|__Deprecated__
377+
| <<plugins-{type}s-{plugin}-truststore_password>> |<<password,password>>|__Deprecated__
371378
| <<plugins-{type}s-{plugin}-upsert>> |<<string,string>>|No
372379
| <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
373380
| <<plugins-{type}s-{plugin}-validate_after_inactivity>> |<<number,number>>|No
@@ -424,8 +431,9 @@ this defaults to a concatenation of the path parameter and "_bulk"
424431

425432
[id="plugins-{type}s-{plugin}-cacert"]
426433
===== `cacert`
434+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>]
427435

428-
* Value type is <<path,path>>
436+
* Value type is a list of <<path,path>>
429437
* There is no default value for this setting.
430438

431439
The .cer or .pem file to validate the server's certificate.
@@ -771,6 +779,7 @@ formats] and the `@timestamp` field of each event is being used as source for th
771779

772780
[id="plugins-{type}s-{plugin}-keystore"]
773781
===== `keystore`
782+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_keystore_path>>]
774783

775784
* Value type is <<path,path>>
776785
* There is no default value for this setting.
@@ -780,6 +789,7 @@ It can be either .jks or .p12
780789

781790
[id="plugins-{type}s-{plugin}-keystore_password"]
782791
===== `keystore_password`
792+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_keystore_password>>]
783793

784794
* Value type is <<password,password>>
785795
* There is no default value for this setting.
@@ -1036,6 +1046,7 @@ do not use full URL here, only paths, e.g. "/sniff/_nodes/http"
10361046

10371047
[id="plugins-{type}s-{plugin}-ssl"]
10381048
===== `ssl`
1049+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
10391050

10401051
* Value type is <<boolean,boolean>>
10411052
* There is no default value for this setting.
@@ -1044,8 +1055,17 @@ Enable SSL/TLS secured communication to Elasticsearch cluster.
10441055
Leaving this unspecified will use whatever scheme is specified in the URLs listed in <<plugins-{type}s-{plugin}-hosts>> or extracted from the <<plugins-{type}s-{plugin}-cloud_id>>.
10451056
If no explicit protocol is specified plain HTTP will be used.
10461057

1058+
[id="plugins-{type}s-{plugin}-ssl_certificate_authorities"]
1059+
===== `ssl_certificate_authorities`
1060+
1061+
* Value type is a list of <<path,path>>
1062+
* There is no default value for this setting
1063+
1064+
The .cer or .pem files to validate the server's certificate.
1065+
10471066
[id="plugins-{type}s-{plugin}-ssl_certificate_verification"]
10481067
===== `ssl_certificate_verification`
1068+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_verification_mode>>]
10491069

10501070
* Value type is <<boolean,boolean>>
10511071
* Default value is `true`
@@ -1054,6 +1074,33 @@ Option to validate the server's certificate. Disabling this severely compromises
10541074
For more information on disabling certificate verification please read
10551075
https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
10561076

1077+
[id="plugins-{type}s-{plugin}-ssl_enabled"]
1078+
===== `ssl_enabled`
1079+
1080+
* Value type is <<boolean,boolean>>
1081+
* There is no default value for this setting.
1082+
1083+
Enable SSL/TLS secured communication to Elasticsearch cluster.
1084+
Leaving this unspecified will use whatever scheme is specified in the URLs listed in <<plugins-{type}s-{plugin}-hosts>> or extracted from the <<plugins-{type}s-{plugin}-cloud_id>>.
1085+
If no explicit protocol is specified plain HTTP will be used.
1086+
1087+
[id="plugins-{type}s-{plugin}-ssl_keystore_password"]
1088+
===== `ssl_keystore_password`
1089+
1090+
* Value type is <<password,password>>
1091+
* There is no default value for this setting.
1092+
1093+
Set the keystore password
1094+
1095+
[id="plugins-{type}s-{plugin}-ssl_keystore_path"]
1096+
===== `ssl_keystore_path`
1097+
1098+
* Value type is <<path,path>>
1099+
* There is no default value for this setting.
1100+
1101+
The keystore used to present a certificate to the server.
1102+
It can be either .jks or .p12
1103+
10571104
[id="plugins-{type}s-{plugin}-ssl_supported_protocols"]
10581105
===== `ssl_supported_protocols`
10591106

@@ -1071,6 +1118,40 @@ NOTE: If you configure the plugin to use `'TLSv1.1'` on any recent JVM, such as
10711118
the protocol is disabled by default and needs to be enabled manually by changing `jdk.tls.disabledAlgorithms` in
10721119
the *$JDK_HOME/conf/security/java.security* configuration file. That is, `TLSv1.1` needs to be removed from the list.
10731120

1121+
[id="plugins-{type}s-{plugin}-ssl_truststore_password"]
1122+
===== `ssl_truststore_password`
1123+
1124+
* Value type is <<password,password>>
1125+
* There is no default value for this setting.
1126+
1127+
Set the truststore password
1128+
1129+
[id="plugins-{type}s-{plugin}-ssl_truststore_path"]
1130+
===== `ssl_truststore_path`
1131+
1132+
* Value type is <<path,path>>
1133+
* There is no default value for this setting.
1134+
1135+
The truststore to validate the server's certificate.
1136+
It can be either .jks or .p12.
1137+
Use either `:truststore` or `:cacert`.
1138+
1139+
[id="plugins-{type}s-{plugin}-ssl_verification_mode"]
1140+
===== `ssl_verification_mode`
1141+
1142+
* Value can be any of: `full`, `none`
1143+
* Default value is `["full"]`
1144+
1145+
Defines how to verify the certificates presented by another party in the TLS connection:
1146+
1147+
`full` validates that the server certificate has an issue date that’s within
1148+
the not_before and not_after dates; chains to a trusted Certificate Authority (CA), and
1149+
has a hostname or IP address that matches the names within the certificate.
1150+
1151+
`none` performs no certificate validation.
1152+
1153+
WARNING: Setting certificate verification to `none` disables many security benefits of SSL/TLS, which is very dangerous. For more information on disabling certificate verification please read https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
1154+
10741155
[id="plugins-{type}s-{plugin}-template"]
10751156
===== `template`
10761157

@@ -1141,6 +1222,7 @@ a timeout occurs, the request will be retried.
11411222

11421223
[id="plugins-{type}s-{plugin}-truststore"]
11431224
===== `truststore`
1225+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_truststore_path>>]
11441226

11451227
* Value type is <<path,path>>
11461228
* There is no default value for this setting.
@@ -1151,6 +1233,7 @@ Use either `:truststore` or `:cacert`.
11511233

11521234
[id="plugins-{type}s-{plugin}-truststore_password"]
11531235
===== `truststore_password`
1236+
deprecated[8.8.0, Replaced by <<plugins-{type}s-{plugin}-ssl_truststore_password>>]
11541237

11551238
* Value type is <<password,password>>
11561239
* There is no default value for this setting.

lib/logstash/outputs/elasticsearch.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,14 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
9696
require "logstash/outputs/elasticsearch/data_stream_support"
9797
require 'logstash/plugin_mixins/ecs_compatibility_support'
9898
require 'logstash/plugin_mixins/deprecation_logger_support'
99+
require 'logstash/plugin_mixins/normalize_config_support'
99100

100101
# Protocol agnostic methods
101102
include(LogStash::PluginMixins::ElasticSearch::Common)
102103

104+
# Config normalization helpers
105+
include(LogStash::PluginMixins::NormalizeConfigSupport)
106+
103107
# Methods for ILM support
104108
include(LogStash::Outputs::ElasticSearch::Ilm)
105109

@@ -279,6 +283,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
279283
def initialize(*params)
280284
super
281285
setup_ecs_compatibility_related_defaults
286+
setup_ssl_params
282287
end
283288

284289
def register
@@ -622,6 +627,52 @@ def setup_template_manager_defaults(data_stream_enabled)
622627
end
623628
end
624629

630+
def setup_ssl_params
631+
@ssl_enabled = normalize_config(:ssl_enabled) do |normalize|
632+
normalize.with_deprecated_alias(:ssl)
633+
end
634+
635+
@ssl_certificate_authorities = normalize_config(:ssl_certificate_authorities) do |normalize|
636+
normalize.with_deprecated_mapping(:cacert) do |cacert|
637+
[cacert]
638+
end
639+
end
640+
641+
@ssl_keystore_path = normalize_config(:ssl_keystore_path) do |normalize|
642+
normalize.with_deprecated_alias(:keystore)
643+
end
644+
645+
@ssl_keystore_password = normalize_config(:ssl_keystore_password) do |normalize|
646+
normalize.with_deprecated_alias(:keystore_password)
647+
end
648+
649+
@ssl_truststore_path = normalize_config(:ssl_truststore_path) do |normalize|
650+
normalize.with_deprecated_alias(:truststore)
651+
end
652+
653+
@ssl_truststore_password = normalize_config(:ssl_truststore_password) do |normalize|
654+
normalize.with_deprecated_alias(:truststore_password)
655+
end
656+
657+
@ssl_verification_mode = normalize_config(:ssl_verification_mode) do |normalize|
658+
normalize.with_deprecated_mapping(:ssl_certificate_verification) do |ssl_certificate_verification|
659+
if ssl_certificate_verification == true
660+
"full"
661+
else
662+
"none"
663+
end
664+
end
665+
end
666+
667+
params['ssl_enabled'] = @ssl_enabled unless @ssl_enabled.nil?
668+
params['ssl_certificate_authorities'] = @ssl_certificate_authorities unless @ssl_certificate_authorities.nil?
669+
params['ssl_keystore_path'] = @ssl_keystore_path unless @ssl_keystore_path.nil?
670+
params['ssl_keystore_password'] = @ssl_keystore_password unless @ssl_keystore_password.nil?
671+
params['ssl_truststore_path'] = @ssl_truststore_path unless @ssl_truststore_path.nil?
672+
params['ssl_truststore_password'] = @ssl_truststore_password unless @ssl_truststore_password.nil?
673+
params['ssl_verification_mode'] = @ssl_verification_mode unless @ssl_verification_mode.nil?
674+
end
675+
625676
# To be overidden by the -java version
626677
VALID_HTTP_ACTIONS = ["index", "delete", "create", "update"]
627678
def valid_actions

lib/logstash/outputs/elasticsearch/http_client_builder.rb

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,42 @@ def self.create_http_client(options)
107107
end
108108

109109
def self.setup_ssl(logger, params)
110-
params["ssl"] = true if params["hosts"].any? {|h| h.scheme == "https" }
111-
return {} if params["ssl"].nil?
110+
params["ssl_enabled"] = true if params["hosts"].any? {|h| h.scheme == "https" }
111+
return {} if params["ssl_enabled"].nil?
112112

113-
return {:ssl => {:enabled => false}} if params["ssl"] == false
113+
return {:ssl => {:enabled => false}} if params["ssl_enabled"] == false
114114

115-
cacert, truststore, truststore_password, keystore, keystore_password =
116-
params.values_at('cacert', 'truststore', 'truststore_password', 'keystore', 'keystore_password')
115+
ssl_certificate_authorities, ssl_truststore_path, ssl_truststore_password, ssl_keystore_path, ssl_keystore_password, ssl_verification_mode =
116+
params.values_at('ssl_certificate_authorities', 'ssl_truststore_path', 'ssl_truststore_password', 'ssl_keystore_path', 'ssl_keystore_password', 'ssl_verification_mode')
117117

118-
if cacert && truststore
119-
raise(LogStash::ConfigurationError, "Use either \"cacert\" or \"truststore\" when configuring the CA certificate") if truststore
118+
if ssl_certificate_authorities && ssl_truststore_path
119+
raise(LogStash::ConfigurationError, "Use either \"ssl_certificate_authorities\" or \"ssl_truststore_path\" when configuring the CA certificate")
120120
end
121121

122122
ssl_options = {:enabled => true}
123123

124-
if cacert
125-
ssl_options[:ca_file] = cacert
126-
elsif truststore
127-
ssl_options[:truststore_password] = truststore_password.value if truststore_password
124+
if ssl_certificate_authorities&.any?
125+
raise(LogStash::ConfigurationError, "Multiple \"ssl_certificate_authorities\" files are not supported") if ssl_certificate_authorities.size > 1
126+
ssl_options[:ca_file] = ssl_certificate_authorities.first
127+
elsif ssl_truststore_path
128+
ssl_options[:truststore_password] = ssl_truststore_password.value if ssl_truststore_password
128129
end
129130

130-
ssl_options[:truststore] = truststore if truststore
131-
if keystore
132-
ssl_options[:keystore] = keystore
133-
ssl_options[:keystore_password] = keystore_password.value if keystore_password
131+
ssl_options[:truststore] = ssl_truststore_path if ssl_truststore_path
132+
if ssl_keystore_path
133+
ssl_options[:keystore] = ssl_keystore_path
134+
ssl_options[:keystore_password] = ssl_keystore_password.value if ssl_keystore_password
134135
end
135136

136-
if !params["ssl_certificate_verification"]
137-
logger.warn "You have enabled encryption but DISABLED certificate verification, " +
138-
"to make sure your data is secure remove `ssl_certificate_verification => false`"
139-
ssl_options[:verify] = :disable # false accepts self-signed but still validates hostname
137+
unless ssl_verification_mode.nil?
138+
case ssl_verification_mode
139+
when 'none'
140+
logger.warn "You have enabled encryption but DISABLED certificate verification, " +
141+
"to make sure your data is secure set `ssl_verification_mode => full`"
142+
ssl_options[:verify] = :disable
143+
else
144+
ssl_options[:verify] = :strict
145+
end
140146
end
141147

142148
ssl_options[:trust_strategy] = params["ssl_trust_strategy"] if params.include?("ssl_trust_strategy")

0 commit comments

Comments
 (0)