Skip to content

Commit 2f28566

Browse files
robbaveydonoghuckarenzone
authored
Mark deprecated SSL settings as obsolete (#58)
* Mark deprecated SSL settings as obsolete This commit marks the following SSL settings as obsolete: `ssl_cert`, which should be replaced by `ssl_certificate` `ssl_cacert`, which should be replaced by `ssl_certificate_authorities` `ssl_enable`, which should be replaced by `ssl_enabled` `ssl_verify`, which should be replaced by `ssl_client_authentication` when `mode` is `server` or `ssl_verification_mode`when mode is `client` --------- Co-authored-by: Cas Donoghue <[email protected]> Co-authored-by: Karen Metts <[email protected]>
1 parent 36ac9b5 commit 2f28566

File tree

5 files changed

+52
-160
lines changed

5 files changed

+52
-160
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 7.0.0
2+
- SSL settings that were marked deprecated in version `6.2.0` are now marked obsolete, and will prevent the plugin from starting.
3+
- These settings are:
4+
- `ssl_cert`, which should be replaced by `ssl_certificate`
5+
- `ssl_cacert`, which should be replaced by `ssl_certificate_authorities`
6+
- `ssl_enable`, which should be replaced by `ssl_enabled`
7+
- `ssl_verify`, which should be replaced by `ssl_client_authentication` when `mode` is `server` or `ssl_verification_mode`when mode is `client`
8+
- [58](https://github.com/logstash-plugins/logstash-output-tcp/pull/58)
19
## 6.2.1
210
- Document correct default plugin codec [#54](https://github.com/logstash-plugins/logstash-output-tcp/pull/54)
311

docs/index.asciidoc

+17-38
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,26 @@ depending on `mode`.
3333

3434
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
3535

36+
NOTE: As of version `7.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed. Please see the
37+
<<plugins-{type}s-{plugin}-obsolete-options>> for more details.
38+
39+
3640
[cols="<,<,<",options="header",]
3741
|=======================================================================
3842
|Setting |Input type|Required
3943
| <<plugins-{type}s-{plugin}-host>> |<<string,string>>|Yes
4044
| <<plugins-{type}s-{plugin}-mode>> |<<string,string>>, one of `["server", "client"]`|No
4145
| <<plugins-{type}s-{plugin}-port>> |<<number,number>>|Yes
4246
| <<plugins-{type}s-{plugin}-reconnect_interval>> |<<number,number>>|No
43-
| <<plugins-{type}s-{plugin}-ssl_cacert>> |a valid filesystem path|__Deprecated__
44-
| <<plugins-{type}s-{plugin}-ssl_cert>> |a valid filesystem path|__Deprecated__
4547
| <<plugins-{type}s-{plugin}-ssl_certificate>> |a valid filesystem path|No
4648
| <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> |<<array,array>>|No
4749
| <<plugins-{type}s-{plugin}-ssl_cipher_suites>> |<<string,string>>|No
4850
| <<plugins-{type}s-{plugin}-ssl_client_authentication>> |<<string,string>>, one of `["none", "optional", "required"]`|No
49-
| <<plugins-{type}s-{plugin}-ssl_enable>> |<<boolean,boolean>>|__Deprecated__
5051
| <<plugins-{type}s-{plugin}-ssl_enabled>> |<<boolean,boolean>>|No
5152
| <<plugins-{type}s-{plugin}-ssl_key>> |a valid filesystem path|No
5253
| <<plugins-{type}s-{plugin}-ssl_key_passphrase>> |<<password,password>>|No
5354
| <<plugins-{type}s-{plugin}-ssl_supported_protocols>> |<<string,string>>|No
5455
| <<plugins-{type}s-{plugin}-ssl_verification_mode>> |<<string,string>>, one of `["full", "none"]`|No
55-
| <<plugins-{type}s-{plugin}-ssl_verify>> |<<boolean,boolean>>|No
5656
|=======================================================================
5757

5858
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
@@ -97,24 +97,6 @@ When mode is `client`, the port to connect to.
9797

9898
When connect failed,retry interval in sec.
9999

100-
[id="plugins-{type}s-{plugin}-ssl_cacert"]
101-
===== `ssl_cacert`
102-
deprecated[6.2.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>]
103-
104-
* Value type is <<path,path>>
105-
* There is no default value for this setting.
106-
107-
The SSL CA certificate, chainfile or CA path. The system CA path is automatically included.
108-
109-
[id="plugins-{type}s-{plugin}-ssl_cert"]
110-
===== `ssl_cert`
111-
deprecated[6.2.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate>>]
112-
113-
* Value type is <<path,path>>
114-
* There is no default value for this setting.
115-
116-
SSL certificate path
117-
118100
[id="plugins-{type}s-{plugin}-ssl_certificate"]
119101
===== `ssl_certificate`
120102

@@ -160,15 +142,6 @@ Please note that the server does not validate the client certificate CN (Common
160142
NOTE: This setting can be used only if <<plugins-{type}s-{plugin}-mode>> is `server` and <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> is set.
161143

162144

163-
[id="plugins-{type}s-{plugin}-ssl_enable"]
164-
===== `ssl_enable`
165-
deprecated[6.2.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
166-
167-
* Value type is <<boolean,boolean>>
168-
* Default value is `false`
169-
170-
Enable SSL (must be set for other `ssl_` options to take effect).
171-
172145
[id="plugins-{type}s-{plugin}-ssl_enabled"]
173146
===== `ssl_enabled`
174147

@@ -223,15 +196,21 @@ has a hostname or IP address that matches the names within the certificate.
223196

224197
NOTE: This setting can be used only if <<plugins-{type}s-{plugin}-mode>> is `client`.
225198

226-
[id="plugins-{type}s-{plugin}-ssl_verify"]
227-
===== `ssl_verify`
228-
deprecated[6.2.0, Replaced by <<plugins-{type}s-{plugin}-ssl_client_authentication>> and <<plugins-{type}s-{plugin}-ssl_verification_mode>>]
199+
[id="plugins-{type}s-{plugin}-obsolete-options"]
200+
==== TCP Output Obsolete Configuration Options
201+
202+
WARNING: As of version `6.0.0` of this plugin, some configuration options have been replaced.
203+
The plugin will fail to start if it contains any of these obsolete options.
229204

230-
* Value type is <<boolean,boolean>>
231-
* Default value is `false`
232205

233-
Verify the identity of the other end of the SSL connection against the CA.
234-
For input, sets the field `sslsubject` to that of the client certificate.
206+
[cols="<,<",options="header",]
207+
|=======================================================================
208+
|Setting|Replaced by
209+
| ssl_cacert |<<plugins-{type}s-{plugin}-ssl_certificate_authorities>>
210+
| ssl_cert |<<plugins-{type}s-{plugin}-ssl_certificate>>
211+
| ssl_enable |<<plugins-{type}s-{plugin}-ssl_enabled>>
212+
| ssl_verify |<<plugins-{type}s-{plugin}-ssl_client_authentication>> in `server` mode and <<plugins-{type}s-{plugin}-ssl_verification_mode>> in `client` mode
213+
|=======================================================================
235214

236215
[id="plugins-{type}s-{plugin}-common-options"]
237216
include::{include_path}/{type}.asciidoc[]

lib/logstash/outputs/tcp.rb

+5-61
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require "logstash/namespace"
44
require "thread"
55
require "logstash/util/socket_peer"
6-
require "logstash/plugin_mixins/normalize_config_support"
76

87
# Write events over a TCP socket.
98
#
@@ -13,8 +12,6 @@
1312
# depending on `mode`.
1413
class LogStash::Outputs::Tcp < LogStash::Outputs::Base
1514

16-
include LogStash::PluginMixins::NormalizeConfigSupport
17-
1815
config_name "tcp"
1916
concurrency :single
2017

@@ -35,9 +32,6 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base
3532
# `client` connects to a server.
3633
config :mode, :validate => ["server", "client"], :default => "client"
3734

38-
# Enable SSL (must be set for other `ssl_` options to take effect).
39-
config :ssl_enable, :validate => :boolean, :default => false, :deprecated => "Use 'ssl_enabled' instead."
40-
4135
# Enable SSL (must be set for other `ssl_` options to take effect).
4236
config :ssl_enabled, :validate => :boolean, :default => false
4337

@@ -48,27 +42,18 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base
4842
# This option needs to be used with `ssl_certificate_authorities` and a defined list of CAs.
4943
config :ssl_client_authentication, :validate => %w[none optional required], :default => 'none'
5044

51-
# Verify the identity of the other end of the SSL connection against the CA.
52-
# For input, sets the field `sslsubject` to that of the client certificate.
53-
config :ssl_verify, :validate => :boolean, :default => false, :deprecated => "Use 'ssl_client_authentication' when `mode` is 'server' or 'ssl_verification_mode' when mode is `client`"
54-
5545
# Options to verify the server's certificate.
5646
# "full": validates that the provided certificate has an issue date that’s within the not_before and not_after dates;
5747
# chains to a trusted Certificate Authority (CA); has a hostname or IP address that matches the names within the certificate.
5848
# "certificate": Validates the provided certificate and verifies that it’s signed by a trusted authority (CA), but does’t check the certificate hostname.
5949
# "none": performs no certificate validation. Disabling this severely compromises security (https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf)
6050
config :ssl_verification_mode, :validate => %w[full none], :default => 'full'
6151

62-
# The SSL CA certificate, chainfile or CA path. The system CA path is automatically included.
63-
config :ssl_cacert, :validate => :path, :deprecated => "Use 'ssl_certificate_authorities' instead."
6452

6553
# Validate client certificate or certificate chain against these authorities. You can define multiple files.
6654
# All the certificates will be read and added to the trust store.
6755
config :ssl_certificate_authorities, :validate => :path, :list => true
6856

69-
# SSL certificate path
70-
config :ssl_cert, :validate => :path, :deprecated => "Use 'ssl_certificate' instead."
71-
7257
# SSL certificate path
7358
config :ssl_certificate, :validate => :path
7459

@@ -84,6 +69,11 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base
8469
# The list of ciphers suite to use
8570
config :ssl_cipher_suites, :validate => :string, :list => true
8671

72+
config :ssl_enable, :obsolete => "Use 'ssl_enabled' instead."
73+
config :ssl_verify, :obsolete => "Use 'ssl_client_authentication' when `mode` is 'server' or 'ssl_verification_mode' when mode is `client`"
74+
config :ssl_cacert, :obsolete => "Use 'ssl_certificate_authorities' instead."
75+
config :ssl_cert, :obsolete => "Use 'ssl_certificate' instead."
76+
8777
class Client
8878

8979
##
@@ -189,11 +179,6 @@ def load_cert_store
189179
end
190180
private :load_cert_store
191181

192-
def initialize(*args)
193-
super(*args)
194-
setup_ssl_params!
195-
end
196-
197182
# @overload Base#register
198183
def register
199184
require "socket"
@@ -405,47 +390,6 @@ def provided_ssl_enabled_config_name
405390
original_params.include?('ssl_enable') ? 'ssl_enable' : 'ssl_enabled'
406391
end
407392

408-
def setup_ssl_params!
409-
@ssl_enabled = normalize_config(:ssl_enabled) do |normalizer|
410-
normalizer.with_deprecated_alias(:ssl_enable)
411-
end
412-
413-
@ssl_certificate = normalize_config(:ssl_certificate) do |normalizer|
414-
normalizer.with_deprecated_alias(:ssl_cert)
415-
end
416-
417-
if server?
418-
@ssl_client_authentication = normalize_config(:ssl_client_authentication) do |normalizer|
419-
normalizer.with_deprecated_mapping(:ssl_verify) do |ssl_verify|
420-
ssl_verify == true ? 'required' : 'none'
421-
end
422-
end
423-
else
424-
@ssl_verification_mode = normalize_config(:ssl_verification_mode) do |normalize|
425-
normalize.with_deprecated_mapping(:ssl_verify) do |ssl_verify|
426-
ssl_verify == true ? 'full' : 'none'
427-
end
428-
end
429-
430-
# Keep backwards compatibility with the default :ssl_verify value (false)
431-
if !original_params.include?('ssl_verify') && !original_params.include?('ssl_verification_mode')
432-
@ssl_verification_mode = 'none'
433-
end
434-
end
435-
436-
@ssl_certificate_authorities = normalize_config(:ssl_certificate_authorities) do |normalize|
437-
normalize.with_deprecated_mapping(:ssl_cacert) do |ssl_cacert|
438-
if File.directory?(ssl_cacert)
439-
Dir.children(ssl_cacert)
440-
.map{ |f| File.join(ssl_cacert, f) }
441-
.reject{ |f| File.directory?(f) || File.basename(f).start_with?('.') }
442-
else
443-
[ssl_cacert]
444-
end
445-
end
446-
end
447-
end
448-
449393
def server?
450394
@mode == "server"
451395
end # def server?

logstash-output-tcp.gemspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-output-tcp'
4-
s.version = '6.2.1'
4+
s.version = '7.0.0'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Writes events over a TCP socket"
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"
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
2424
s.add_runtime_dependency 'logstash-core', '>= 8.1.0'
2525
s.add_runtime_dependency 'logstash-codec-json'
2626
s.add_runtime_dependency 'stud'
27-
s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'
2827

2928
s.add_runtime_dependency 'jruby-openssl', '>= 0.12.2' # 0.12 supports TLSv1.3
3029

spec/outputs/tcp_spec.rb

+21-59
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@
2424

2525
let(:event) { LogStash::Event.new('message' => 'foo bar') }
2626

27+
['server', 'client'].each do |mode|
28+
describe "handling obsolete settings for #{mode} mode" do
29+
[{:name => 'ssl_cert', :replacement => 'ssl_certificate', :sample_value => "certificate_path"},
30+
{:name => 'ssl_cacert', :replacement => 'ssl_certificate_authorities', :sample_value => "certificate_path"},
31+
{:name => 'ssl_enable', :replacement => 'ssl_enabled', :sample_value => true},
32+
{:name => 'ssl_verify', :replacement => 'ssl_client_authentication', :sample_value => 'peer'}].each do | obsolete_setting |
33+
context "with obsolete #{obsolete_setting[:name]}" do
34+
let (:deprecated_config) do
35+
config.merge({'mode' => mode, obsolete_setting[:name] => obsolete_setting[:sample_value]})
36+
end
37+
38+
it "should raise a config error with the appropriate message" do
39+
expect { LogStash::Outputs::Tcp.new(deprecated_config).register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `tcp` is obsolete and is no longer available. Use '#{obsolete_setting[:replacement]}'/i
40+
end
41+
end
42+
end
43+
end
44+
end
45+
2746
context 'failing to connect' do
2847

2948
before { subject.register }
@@ -214,7 +233,7 @@
214233

215234
context 'with supported protocol' do
216235

217-
let(:config) { super().merge("ssl_supported_protocols" => ['TLSv1.2']) }
236+
let(:config) { super().merge("ssl_supported_protocols" => ['TLSv1.2'], "ssl_verification_mode" => "none") }
218237

219238
let(:server_min_version) { 'TLS1_2' }
220239

@@ -277,7 +296,7 @@
277296
context "and protocol is TLSv1.3" do
278297
let(:key_file) { File.join(FIXTURES_PATH, 'plaintext/instance.key') }
279298
let(:crt_file) { File.join(FIXTURES_PATH, 'plaintext/instance.crt') }
280-
let(:config) { super().merge("ssl_certificate" => crt_file, "ssl_key" => key_file) }
299+
let(:config) { super().merge("ssl_certificate" => crt_file, "ssl_key" => key_file, "ssl_verification_mode" => "none") }
281300

282301
let(:secure_server) do
283302
ssl_context = OpenSSL::SSL::SSLContext.new
@@ -374,16 +393,6 @@
374393
end
375394
end
376395

377-
context "with deprecated ssl_verify = true and no ssl_certificate_authorities" do
378-
let(:config) { super().merge(
379-
'ssl_verify' => true,
380-
'ssl_certificate_authorities' => []
381-
) }
382-
383-
it "should register without errors" do
384-
expect { subject.register }.to_not raise_error
385-
end
386-
end
387396

388397
%w[required optional].each do |ssl_client_authentication|
389398
context "with ssl_client_authentication = `#{ssl_client_authentication}` and no ssl_certificate_authorities" do
@@ -409,53 +418,6 @@
409418
end
410419
end
411420

412-
context "with deprecated settings" do
413-
let(:ssl_verify) { true }
414-
let(:certificate_path) { File.join(FIXTURES_PATH, 'plaintext/instance.crt') }
415-
let(:config) do
416-
{
417-
"host" => "127.0.0.1",
418-
"port" => port,
419-
"ssl_enable" => true,
420-
"ssl_cert" => certificate_path,
421-
"ssl_key" => File.join(FIXTURES_PATH, 'plaintext/instance.key'),
422-
"ssl_verify" => ssl_verify
423-
}
424-
end
425-
426-
context "and mode is server" do
427-
let(:config) { super().merge("mode" => 'server') }
428-
[true, false].each do |verify|
429-
context "and ssl_verify is #{verify}" do
430-
let(:ssl_verify) { verify }
431-
432-
it "should set new configs variables" do
433-
subject.register
434-
expect(subject.instance_variable_get(:@ssl_enabled)).to eql(true)
435-
expect(subject.instance_variable_get(:@ssl_client_authentication)).to eql(verify ? 'required' : 'none')
436-
expect(subject.instance_variable_get(:@ssl_certificate)).to eql(certificate_path)
437-
end
438-
end
439-
end
440-
end
441-
442-
context "and mode is client" do
443-
let(:config) { super().merge("mode" => 'client') }
444-
[true, false].each do |verify|
445-
context "and ssl_verify is #{verify}" do
446-
let(:ssl_verify) { verify }
447-
448-
it "should set new configs variables" do
449-
subject.register
450-
expect(subject.instance_variable_get(:@ssl_enabled)).to eql(true)
451-
expect(subject.instance_variable_get(:@ssl_verification_mode)).to eql(verify ? 'full' : 'none')
452-
expect(subject.instance_variable_get(:@ssl_certificate)).to eql(certificate_path)
453-
end
454-
end
455-
end
456-
end
457-
end
458-
459421
context "with ssl_client_authentication" do
460422
let(:config) do
461423
super().merge 'ssl_client_authentication' => 'required'

0 commit comments

Comments
 (0)