Skip to content

Commit 56d923f

Browse files
authored
Remove deprecated SSL settings and simplify SSL configuration (#213)
* Mark deprecated SSL settings as obsolete This commit updates SSL settings to be marked as obsolete: - Replace `ssl` with `ssl_enabled` - Replace `ca_file` with `ssl_certificate_authorities` - Replace `ssl_certificate_verification` with `ssl_verification_mode` `setup_ssl_params!` has been updated to only handle SSL inference when not explicitly configured. * Fix accidental removal of changelog entry During a rebase the latest 4 series entry was deleted. This restores it.
1 parent f49b710 commit 56d923f

File tree

5 files changed

+49
-91
lines changed

5 files changed

+49
-91
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 5.0.0
2+
- SSL settings that were marked deprecated in version `4.17.0` are now marked obsolete, and will prevent the plugin from starting.
3+
- These settings are:
4+
- `ssl`, which should bre replaced by `ssl_enabled`
5+
- `ca_file`, which should bre replaced by `ssl_certificate_authorities`
6+
- `ssl_certificate_verification`, which should bre replaced by `ssl_verification_mode`
7+
- [#213](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/213)
8+
19
## 4.20.5
210
- Add `x-elastic-product-origin` header to Elasticsearch requests [#211](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/211)
311

docs/index.asciidoc

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ TIP: Set the `target` option to avoid potential schema conflicts.
9696
[id="plugins-{type}s-{plugin}-options"]
9797
==== Elasticsearch Input configuration options
9898

99-
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> and the <<plugins-{type}s-{plugin}-deprecated-options>> described later.
99+
This plugin supports these configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
100+
101+
NOTE: As of version `5.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed.
102+
Please check out <<plugins-{type}s-{plugin}-obsolete-options>> for details.
103+
104+
NOTE: As of version `5.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed.
105+
Please check out <<plugins-{type}s-{plugin}-obsolete-options>> for details.
100106

101107
[cols="<,<,<",options="header",]
102108
|=======================================================================
@@ -478,6 +484,8 @@ Enable SSL/TLS secured communication to Elasticsearch cluster.
478484
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>>.
479485
If no explicit protocol is specified plain HTTP will be used.
480486

487+
When not explicitly set, SSL will be automatically enabled if any of the specified hosts use HTTPS.
488+
481489
[id="plugins-{type}s-{plugin}-ssl_key"]
482490
===== `ssl_key`
483491
* Value type is <<path,path>>
@@ -608,56 +616,21 @@ option when authenticating to the Elasticsearch server. If set to an
608616
empty string authentication will be disabled.
609617

610618

611-
[id="plugins-{type}s-{plugin}-deprecated-options"]
612-
==== Elasticsearch Input deprecated configuration options
619+
[id="plugins-{type}s-{plugin}-obsolete-options"]
620+
==== Elasticsearch Input Obsolete Configuration Options
613621

614-
This plugin supports the following deprecated configurations.
622+
WARNING: As of version `5.0.0` of this plugin, some configuration options have been replaced.
623+
The plugin will fail to start if it contains any of these obsolete options.
615624

616-
WARNING: Deprecated options are subject to removal in future releases.
617625

618-
[cols="<,<,<",options="header",]
626+
[cols="<,<",options="header",]
619627
|=======================================================================
620-
|Setting|Input type|Replaced by
621-
| <<plugins-{type}s-{plugin}-ca_file>> |a valid filesystem path|<<plugins-{type}s-{plugin}-ssl_certificate_authorities>>
622-
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|<<plugins-{type}s-{plugin}-ssl_enabled>>
623-
| <<plugins-{type}s-{plugin}-ssl_certificate_verification>> |<<boolean,boolean>>|<<plugins-{type}s-{plugin}-ssl_verification_mode>>
628+
|Setting|Replaced by
629+
| ca_file | <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>
630+
| ssl | <<plugins-{type}s-{plugin}-ssl_enabled>>
631+
| ssl_certificate_verification | <<plugins-{type}s-{plugin}-ssl_verification_mode>>
624632
|=======================================================================
625633

626-
[id="plugins-{type}s-{plugin}-ca_file"]
627-
===== `ca_file`
628-
deprecated[4.17.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>]
629-
630-
* Value type is <<path,path>>
631-
* There is no default value for this setting.
632-
633-
SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary.
634-
635-
[id="plugins-{type}s-{plugin}-ssl"]
636-
===== `ssl`
637-
deprecated[4.17.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
638-
639-
* Value type is <<boolean,boolean>>
640-
* Default value is `false`
641-
642-
If enabled, SSL will be used when communicating with the Elasticsearch
643-
server (i.e. HTTPS will be used instead of plain HTTP).
644-
645-
646-
[id="plugins-{type}s-{plugin}-ssl_certificate_verification"]
647-
===== `ssl_certificate_verification`
648-
deprecated[4.17.0, Replaced by <<plugins-{type}s-{plugin}-ssl_verification_mode>>]
649-
650-
* Value type is <<boolean,boolean>>
651-
* Default value is `true`
652-
653-
Option to validate the server's certificate. Disabling this severely compromises security.
654-
When certificate validation is disabled, this plugin implicitly trusts the machine
655-
resolved at the given address without validating its proof-of-identity.
656-
In this scenario, the plugin can transmit credentials to or process data from an untrustworthy
657-
man-in-the-middle or other compromised infrastructure.
658-
More information on the importance of certificate verification:
659-
**https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf**.
660-
661634
[id="plugins-{type}s-{plugin}-common-options"]
662635
include::{include_path}/{type}.asciidoc[]
663636

lib/logstash/inputs/elasticsearch.rb

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,12 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
198198
# Set the address of a forward HTTP proxy.
199199
config :proxy, :validate => :uri_or_empty
200200

201-
# SSL
202-
config :ssl, :validate => :boolean, :default => false, :deprecated => "Set 'ssl_enabled' instead."
203-
204-
# SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary
205-
config :ca_file, :validate => :path, :deprecated => "Set 'ssl_certificate_authorities' instead."
206-
207201
# OpenSSL-style X.509 certificate certificate to authenticate the client
208202
config :ssl_certificate, :validate => :path
209203

210204
# SSL Certificate Authority files in PEM encoded format, must also include any chain certificates as necessary
211205
config :ssl_certificate_authorities, :validate => :path, :list => true
212206

213-
# Option to validate the server's certificate. Disabling this severely compromises security.
214-
# For more information on the importance of certificate verification please read
215-
# https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
216-
config :ssl_certificate_verification, :validate => :boolean, :default => true, :deprecated => "Set 'ssl_verification_mode' instead."
217-
218207
# The list of cipher suites to use, listed by priorities.
219208
# Supported cipher suites vary depending on which version of Java is used.
220209
config :ssl_cipher_suites, :validate => :string, :list => true
@@ -242,7 +231,6 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
242231
config :ssl_truststore_password, :validate => :password
243232

244233
# The JKS truststore to validate the server's certificate.
245-
# Use either `:ssl_truststore_path` or `:ssl_certificate_authorities`
246234
config :ssl_truststore_path, :validate => :path
247235

248236
# The format of the truststore file. It must be either jks or pkcs12
@@ -264,6 +252,11 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
264252
# If set, the _source of each hit will be added nested under the target instead of at the top-level
265253
config :target, :validate => :field_reference
266254

255+
# Obsolete Settings
256+
config :ssl, :obsolete => "Set 'ssl_enabled' instead."
257+
config :ca_file, :obsolete => "Set 'ssl_certificate_authorities' instead."
258+
config :ssl_certificate_verification, :obsolete => "Set 'ssl_verification_mode' instead."
259+
267260
# config :ca_trusted_fingerprint, :validate => :sha_256_hex
268261
include LogStash::PluginMixins::CATrustedFingerprintSupport
269262

@@ -408,8 +401,6 @@ def setup_client_ssl
408401
ssl_options[:ssl] = true if @ssl_enabled
409402

410403
unless @ssl_enabled
411-
# Keep it backward compatible with the deprecated `ssl` option
412-
ssl_options[:trust_strategy] = trust_strategy_for_ca_trusted_fingerprint if original_params.include?('ssl')
413404
return ssl_options
414405
end
415406

@@ -473,38 +464,11 @@ def setup_client_ssl
473464
end
474465

475466
def setup_ssl_params!
476-
@ssl_enabled = normalize_config(:ssl_enabled) do |normalize|
477-
normalize.with_deprecated_alias(:ssl)
478-
end
479-
480-
# Infer the value if neither the deprecate `ssl` and `ssl_enabled` were set
481-
infer_ssl_enabled_from_hosts
482-
483-
@ssl_certificate_authorities = normalize_config(:ssl_certificate_authorities) do |normalize|
484-
normalize.with_deprecated_mapping(:ca_file) do |ca_file|
485-
[ca_file]
486-
end
467+
# Only infer ssl_enabled if it wasn't explicitly set
468+
unless original_params.include?('ssl_enabled')
469+
@ssl_enabled = effectively_ssl?
470+
params['ssl_enabled'] = @ssl_enabled
487471
end
488-
489-
@ssl_verification_mode = normalize_config(:ssl_verification_mode) do |normalize|
490-
normalize.with_deprecated_mapping(:ssl_certificate_verification) do |ssl_certificate_verification|
491-
if ssl_certificate_verification == true
492-
"full"
493-
else
494-
"none"
495-
end
496-
end
497-
end
498-
499-
params['ssl_enabled'] = @ssl_enabled
500-
params['ssl_certificate_authorities'] = @ssl_certificate_authorities unless @ssl_certificate_authorities.nil?
501-
params['ssl_verification_mode'] = @ssl_verification_mode unless @ssl_verification_mode.nil?
502-
end
503-
504-
def infer_ssl_enabled_from_hosts
505-
return if original_params.include?('ssl') || original_params.include?('ssl_enabled')
506-
507-
@ssl_enabled = params['ssl_enabled'] = effectively_ssl?
508472
end
509473

510474
def setup_hosts

logstash-input-elasticsearch.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-input-elasticsearch'
4-
s.version = '4.20.5'
4+
s.version = '5.0.0'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Reads query results from an Elasticsearch cluster"
77
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

spec/inputs/elasticsearch_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@
5858
end
5959
end
6060

61+
describe 'handling obsolete settings' do
62+
[{:name => 'ssl', :replacement => 'ssl_enabled', :sample_value => true},
63+
{:name => 'ca_file', :replacement => 'ssl_certificate_authorities', :sample_value => 'spec/fixtures/test_certs/ca.crt'},
64+
{:name => 'ssl_certificate_verification', :replacement => 'ssl_verification_mode', :sample_value => false }].each do | obsolete_setting|
65+
context "with obsolete #{obsolete_setting[:name]}" do
66+
let (:config) { {obsolete_setting[:name] => obsolete_setting[:sample_value]} }
67+
it "should raise a config error with the appropriate message" do
68+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `elasticsearch` is obsolete and is no longer available. Set '#{obsolete_setting[:replacement]}' instead/i
69+
end
70+
end
71+
end
72+
end
73+
6174
context "against not authentic Elasticsearch" do
6275
before(:each) do
6376
Elasticsearch::Client.send(:define_method, :ping) { raise Elasticsearch::UnsupportedProductError.new("Fake error") } # define error ping method

0 commit comments

Comments
 (0)