logstash-input-http 3.6.0-java → 3.7.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa318266e4bda14335b9ff0a9334d984e0a52cecaefa7037a064aef4e8df7015
4
- data.tar.gz: efe4a565498fda944f2b2e9a91813a2ecc70ed9b4a89bae7ba2730221eef8549
3
+ metadata.gz: 8f51c4bbd6f822ca86e04cf3895e6084f6eb7c3ce3c860dd4cd634960083925d
4
+ data.tar.gz: 58d2c5e3bf67f11808a7eae4aa2ee0dd66d344233548b92180b3ef9743a3ffcd
5
5
  SHA512:
6
- metadata.gz: b52359e3a884877733f41ce7885bba97dc578db0c4fbdf708a498a13cc06a38efc319b2e72f5f788d6287f0c8a33f419a811e01776661e1eea313682948439d7
7
- data.tar.gz: e953789900e9f5d98593c3d83ad1d100b83433abf109a708c90c2eb04291d18f1339419a6f498a830103ba894bac03a02944094495873260a9cfab9c1c8ae666
6
+ metadata.gz: 30fe8ab9b1b965dfe60b453aad5cbb6ca00ea994d6d1dbb7ac4bb2d28d095a491ca15c7c2ba295fe7f2f25df3f5d96d882f9a377f34c9cb372fc766dcd745028
7
+ data.tar.gz: ffadf395fc47657426445cf47f9b8c0da277c68edf73020154c4e62dc7e8313b28bd2cc7f6c9e06907be89b651cdf44d294f45974f67aae0aaf1f039fff308ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 3.7.0
2
+ - Reviewed and deprecated SSL settings to comply with Logstash's naming convention [#165](https://github.com/logstash-plugins/logstash-input-http/pull/165)
3
+ - Deprecated `ssl` in favor of `ssl_enabled`
4
+ - Deprecated `ssl_verify_mode` in favor of `ssl_client_authentication`
5
+ - Deprecated `keystore` in favor of `ssl_keystore_path`
6
+ - Deprecated `keystore_password` in favor of `ssl_keystore_password`
7
+
8
+ ## 3.6.1
9
+ - Update Netty dependency to 4.1.87 [#162](https://github.com/logstash-plugins/logstash-input-http/pull/162)
10
+
1
11
  ## 3.6.0
2
12
  - Feat: review and deprecate ssl protocol/cipher related settings [#151](https://github.com/logstash-plugins/logstash-input-http/pull/151)
3
13
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.6.0
1
+ 3.7.0
data/docs/index.asciidoc CHANGED
@@ -91,30 +91,34 @@ This plugin supports the following configuration options plus the <<plugins-{typ
91
91
  |=======================================================================
92
92
  |Setting |Input type|Required
93
93
  | <<plugins-{type}s-{plugin}-additional_codecs>> |<<hash,hash>>|No
94
- | <<plugins-{type}s-{plugin}-cipher_suites>> |<<array,array>>|No
94
+ | <<plugins-{type}s-{plugin}-cipher_suites>> |<<array,array>>|__Deprecated__
95
95
  | <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
96
96
  | <<plugins-{type}s-{plugin}-host>> |<<string,string>>|No
97
- | <<plugins-{type}s-{plugin}-keystore>> |<<path,path>>|No
98
- | <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|No
97
+ | <<plugins-{type}s-{plugin}-keystore>> |<<path,path>>|__Deprecated__
98
+ | <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|__Deprecated__
99
99
  | <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
100
100
  | <<plugins-{type}s-{plugin}-port>> |<<number,number>>|No
101
101
  | <<plugins-{type}s-{plugin}-max_pending_requests>> |<<number,number>>|No
102
102
  | <<plugins-{type}s-{plugin}-response_headers>> |<<hash,hash>>|No
103
103
  | <<plugins-{type}s-{plugin}-response_code>> |<<number,number>>, one of `[200, 201, 202, 204]`|No
104
- | <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|No
104
+ | <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|__Deprecated__
105
105
  | <<plugins-{type}s-{plugin}-ssl_certificate>> |a valid filesystem path|No
106
106
  | <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> |<<array,array>>|No
107
107
  | <<plugins-{type}s-{plugin}-ssl_cipher_suites>> |<<array,array>>|No
108
+ | <<plugins-{type}s-{plugin}-ssl_client_authentication>> |<<string,string>>, one of `["none", "optional", "required"]`|No
109
+ | <<plugins-{type}s-{plugin}-ssl_enabled>> |<<boolean,boolean>>|No
108
110
  | <<plugins-{type}s-{plugin}-ssl_handshake_timeout>> |<<number,number>>|No
109
111
  | <<plugins-{type}s-{plugin}-ssl_key>> |a valid filesystem path|No
110
112
  | <<plugins-{type}s-{plugin}-ssl_key_passphrase>> |<<password,password>>|No
113
+ | <<plugins-{type}s-{plugin}-ssl_keystore_password>> |<<password,password>>|No
114
+ | <<plugins-{type}s-{plugin}-ssl_keystore_path>> |<<path,path>>|No
111
115
  | <<plugins-{type}s-{plugin}-ssl_supported_protocols>> |<<array,array>>|No
112
- | <<plugins-{type}s-{plugin}-ssl_verify_mode>> |<<string,string>>, one of `["none", "peer", "force_peer"]`|No
116
+ | <<plugins-{type}s-{plugin}-ssl_verify_mode>> |<<string,string>>, one of `["none", "peer", "force_peer"]`|__Deprecated__
113
117
  | <<plugins-{type}s-{plugin}-threads>> |<<number,number>>|No
114
- | <<plugins-{type}s-{plugin}-tls_max_version>> |<<number,number>>|No
115
- | <<plugins-{type}s-{plugin}-tls_min_version>> |<<number,number>>|No
118
+ | <<plugins-{type}s-{plugin}-tls_max_version>> |<<number,number>>|__Deprecated__
119
+ | <<plugins-{type}s-{plugin}-tls_min_version>> |<<number,number>>|__Deprecated__
116
120
  | <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
117
- | <<plugins-{type}s-{plugin}-verify_mode>> |<<string,string>>, one of `["none", "peer", "force_peer"]`|No
121
+ | <<plugins-{type}s-{plugin}-verify_mode>> |<<string,string>>, one of `["none", "peer", "force_peer"]`|__Deprecated__
118
122
  |=======================================================================
119
123
 
120
124
  Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
@@ -134,29 +138,24 @@ and no codec for the request's content-type is found
134
138
 
135
139
  [id="plugins-{type}s-{plugin}-cipher_suites"]
136
140
  ===== `cipher_suites`
141
+ deprecated[3.6.0, Replaced by <<plugins-{type}s-{plugin}-ssl_cipher_suites>>]
137
142
 
138
143
  * Value type is <<array,array>>
139
- * This option is deprecated
140
144
 
141
145
  The list of cipher suites to use, listed by priorities.
142
146
 
143
- NOTE: This option is deprecated and it will be removed in the next major version of Logstash.
144
- Use `ssl_cipher_suites` instead.
145
-
146
147
  [id="plugins-{type}s-{plugin}-ecs_compatibility"]
147
148
  ===== `ecs_compatibility`
148
149
 
149
150
  * Value type is <<string,string>>
150
151
  * Supported values are:
151
- ** `disabled`: unstructured connection metadata added at root level
152
- ** `v1`,`v8`: headers added under `[@metadata][http][header]`. Some are copied to structured ECS fields `http`, `url`, `user_agent` and `host`
152
+ ** `disabled`: unstructured connection metadata added at root level
153
+ ** `v1`,`v8`: headers added under `[@metadata][http][header]`. Some are copied to structured ECS fields `http`, `url`, `user_agent` and `host`
153
154
 
154
155
  Controls this plugin's compatibility with the
155
156
  {ecs-ref}[Elastic Common Schema (ECS)].
156
157
  See <<plugins-{type}s-{plugin}-ecs_metadata>> for detailed information.
157
158
 
158
- Example output:
159
-
160
159
  **Sample output: ECS disabled**
161
160
  [source,text]
162
161
  -----
@@ -219,27 +218,21 @@ The host or ip to bind
219
218
 
220
219
  [id="plugins-{type}s-{plugin}-keystore"]
221
220
  ===== `keystore`
221
+ deprecated[3.7.0, Use <<plugins-{type}s-{plugin}-ssl_keystore_path>> instead]
222
222
 
223
223
  * Value type is <<path,path>>
224
224
  * There is no default value for this setting.
225
- * This option is deprecated
226
225
 
227
226
  The JKS keystore to validate the client's certificates
228
227
 
229
- Note: This option is deprecated and it will be removed in the next major version of Logstash.
230
- Use `ssl_certificate` and `ssl_key` instead.
231
-
232
228
  [id="plugins-{type}s-{plugin}-keystore_password"]
233
229
  ===== `keystore_password`
230
+ deprecated[3.7.0, Use <<plugins-{type}s-{plugin}-ssl_keystore_password>> instead]
234
231
 
235
232
  * Value type is <<password,password>>
236
233
  * There is no default value for this setting.
237
- * This option is deprecated
238
234
 
239
- Set the truststore password
240
-
241
- Note: This option is deprecated and it will be removed in the next major version of Logstash.
242
- Use `ssl_certificate` and `ssl_key` instead.
235
+ Set the keystore password
243
236
 
244
237
  [id="plugins-{type}s-{plugin}-password"]
245
238
  ===== `password`
@@ -319,11 +312,12 @@ specify target field for the client host of the http request
319
312
 
320
313
  [id="plugins-{type}s-{plugin}-ssl"]
321
314
  ===== `ssl`
315
+ deprecated[3.7.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
322
316
 
323
317
  * Value type is <<boolean,boolean>>
324
318
  * Default value is `false`
325
319
 
326
- Events are by default sent in plain text. You can
320
+ Events are, by default, sent in plain text. You can
327
321
  enable encryption by setting `ssl` to true and configuring
328
322
  the `ssl_certificate` and `ssl_key` options.
329
323
 
@@ -343,8 +337,8 @@ SSL certificate to use.
343
337
 
344
338
  Validate client certificates against these authorities.
345
339
  You can define multiple files or paths. All the certificates will
346
- be read and added to the trust store. You need to configure the `ssl_verify_mode`
347
- to `peer` or `force_peer` to enable the verification.
340
+ be read and added to the trust store. You need to configure the <<plugins-{type}s-{plugin}-ssl_client_authentication>>
341
+ to `optional` or `required` to enable the verification.
348
342
 
349
343
 
350
344
  [id="plugins-{type}s-{plugin}-ssl_cipher_suites"]
@@ -358,6 +352,27 @@ This default list applies for OpenJDK 11.0.14 and higher.
358
352
  For older JDK versions, the default list includes only suites supported by that version.
359
353
  For example, the ChaCha20 family of ciphers is not supported in older versions.
360
354
 
355
+ [id="plugins-{type}s-{plugin}-ssl_client_authentication"]
356
+ ===== `ssl_client_authentication`
357
+
358
+ * Value can be any of: `none`, `optional`, `required`
359
+ * Default value is `"none"`
360
+
361
+ Controls the server's behavior in regard to requesting a certificate from client connections:
362
+ `required` forces a client to present a certificate, while `optional` requests a client certificate
363
+ but the client is not required to present one. Defaults to `none`, which disables the client authentication.
364
+
365
+ NOTE: This setting can be used only if <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> is set.
366
+
367
+ [id="plugins-{type}s-{plugin}-ssl_enabled"]
368
+ ===== `ssl_enabled`
369
+
370
+ * Value type is <<boolean,boolean>>
371
+ * Default value is `false`
372
+
373
+ Events are, by default, sent in plain text. You can enable encryption by setting `ssl_enabled` to true and configuring
374
+ the <<plugins-{type}s-{plugin}-ssl_certificate>> and <<plugins-{type}s-{plugin}-ssl_key>> options.
375
+
361
376
  [id="plugins-{type}s-{plugin}-ssl_handshake_timeout"]
362
377
  ===== `ssl_handshake_timeout`
363
378
 
@@ -384,6 +399,22 @@ for more information.
384
399
 
385
400
  SSL key passphrase to use.
386
401
 
402
+ [id="plugins-{type}s-{plugin}-ssl_keystore_path"]
403
+ ===== `ssl_keystore_path`
404
+
405
+ * Value type is <<path,path>>
406
+ * There is no default value for this setting.
407
+
408
+ The JKS keystore to validate the client's certificates
409
+
410
+ [id="plugins-{type}s-{plugin}-ssl_keystore_password"]
411
+ ===== `ssl_keystore_password`
412
+
413
+ * Value type is <<password,password>>
414
+ * There is no default value for this setting.
415
+
416
+ Set the JKS keystore password
417
+
387
418
  [id="plugins-{type}s-{plugin}-ssl_supported_protocols"]
388
419
  ===== `ssl_supported_protocols`
389
420
 
@@ -403,6 +434,7 @@ the *$JDK_HOME/conf/security/java.security* configuration file. That is, `TLSv1.
403
434
 
404
435
  [id="plugins-{type}s-{plugin}-ssl_verify_mode"]
405
436
  ===== `ssl_verify_mode`
437
+ deprecated[3.7.0, Replaced by <<plugins-{type}s-{plugin}-ssl_client_authentication>>]
406
438
 
407
439
  * Value can be any of: `none`, `peer`, `force_peer`
408
440
  * Default value is `"none"`
@@ -415,7 +447,7 @@ If the client provides a certificate, it will be validated.
415
447
  `force_peer` will make the server ask the client to provide a certificate.
416
448
  If the client doesn't provide a certificate, the connection will be closed.
417
449
 
418
- This option needs to be used with `ssl_certificate_authorities` and a defined list of CAs.
450
+ This option needs to be used with <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> and a defined list of CAs.
419
451
 
420
452
  [id="plugins-{type}s-{plugin}-threads"]
421
453
  ===== `threads`
@@ -427,18 +459,18 @@ Number of threads to use for both accepting connections and handling requests
427
459
 
428
460
  [id="plugins-{type}s-{plugin}-tls_max_version"]
429
461
  ===== `tls_max_version`
462
+ deprecated[3.6.0]
430
463
 
431
464
  * Value type is <<number,number>>
432
- * This option is deprecated
433
465
 
434
466
  The maximum TLS version allowed for the encrypted connections.
435
467
  The value must be the one of the following: 1.1 for TLS 1.1, 1.2 for TLS 1.2, 1.3 for TLSv1.3
436
468
 
437
469
  [id="plugins-{type}s-{plugin}-tls_min_version"]
438
470
  ===== `tls_min_version`
471
+ deprecated[3.6.0]
439
472
 
440
473
  * Value type is <<number,number>>
441
- * This option is deprecated
442
474
 
443
475
  The minimum TLS version allowed for the encrypted connections.
444
476
  The value must be one of the following: 1.1 for TLS 1.1, 1.2 for TLS 1.2, 1.3 for TLSv1.3
@@ -453,16 +485,13 @@ Username for basic authorization
453
485
 
454
486
  [id="plugins-{type}s-{plugin}-verify_mode"]
455
487
  ===== `verify_mode`
488
+ deprecated[3.6.0, Replaced by <<plugins-{type}s-{plugin}-ssl_verify_mode>>]
456
489
 
457
490
  * Value can be any of: `none`, `peer`, `force_peer`
458
491
  * Default value is `"none"`
459
- * This option is deprecated
460
492
 
461
493
  Set the client certificate verification method. Valid methods: none, peer, force_peer
462
494
 
463
- NOTE: This option is deprecated and it will be removed in the next major version of Logstash.
464
- Use `ssl_verify_mode` instead.
465
-
466
495
 
467
496
  [id="plugins-{type}s-{plugin}-common-options"]
468
497
  include::{include_path}/{type}.asciidoc[]
@@ -4,6 +4,7 @@ require "logstash/namespace"
4
4
  require "stud/interval"
5
5
  require "logstash-input-http_jars"
6
6
  require "logstash/plugin_mixins/ecs_compatibility_support"
7
+ require "logstash/plugin_mixins/normalize_config_support"
7
8
 
8
9
  # Using this input you can receive single or multiline events over http(s).
9
10
  # Applications can send a HTTP POST request with a body to the endpoint started by this
@@ -27,6 +28,9 @@ require "logstash/plugin_mixins/ecs_compatibility_support"
27
28
  #
28
29
  class LogStash::Inputs::Http < LogStash::Inputs::Base
29
30
  include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8 => :v1)
31
+
32
+ include LogStash::PluginMixins::NormalizeConfigSupport
33
+
30
34
  require "logstash/inputs/http/tls"
31
35
 
32
36
  java_import "io.netty.handler.codec.http.HttpUtil"
@@ -54,7 +58,12 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
54
58
  # Events are by default sent in plain text. You can
55
59
  # enable encryption by setting `ssl` to true and configuring
56
60
  # the `ssl_certificate` and `ssl_key` options.
57
- config :ssl, :validate => :boolean, :default => false
61
+ config :ssl, :validate => :boolean, :default => false, :deprecated => "Set 'ssl_enabled' instead."
62
+
63
+ # Events are by default sent in plain text. You can
64
+ # enable encryption by setting `ssl` to true and configuring
65
+ # the `ssl_certificate` and `ssl_key` options.
66
+ config :ssl_enabled, :validate => :boolean, :default => false
58
67
 
59
68
  # SSL certificate to use.
60
69
  config :ssl_certificate, :validate => :path
@@ -64,15 +73,29 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
64
73
  # for more information.
65
74
  config :ssl_key, :validate => :path
66
75
 
76
+ # The JKS keystore password
77
+ config :ssl_keystore_password, :validate => :password
78
+
79
+ # The JKS keystore to validate the client's certificates
80
+ config :ssl_keystore_path, :validate => :path
81
+
67
82
  # SSL key passphrase to use.
68
83
  config :ssl_key_passphrase, :validate => :password
69
84
 
70
85
  # Validate client certificates against these authorities.
71
86
  # You can define multiple files or paths. All the certificates will
72
- # be read and added to the trust store. You need to configure the `ssl_verify_mode`
73
- # to `peer` or `force_peer` to enable the verification.
87
+ # be read and added to the trust store. You need to configure the `ssl_client_authentication`
88
+ # to `optional` or `required` to enable the verification.
74
89
  config :ssl_certificate_authorities, :validate => :array, :default => []
75
90
 
91
+ # Controls the server’s behavior in regard to requesting a certificate from client connections.
92
+ # `none`: No client authentication
93
+ # `optional`: Requests a client certificate but the client is not required to present one.
94
+ # `required`: Forces a client to present a certificate.
95
+ #
96
+ # This option needs to be used with `ssl_certificate_authorities` and a defined list of CAs.
97
+ config :ssl_client_authentication, :validate => %w[none optional required], :default => 'none'
98
+
76
99
  # By default the server doesn't do any client verification.
77
100
  #
78
101
  # `peer` will make the server ask the client to provide a certificate.
@@ -82,7 +105,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
82
105
  # If the client doesn't provide a certificate, the connection will be closed.
83
106
  #
84
107
  # This option needs to be used with `ssl_certificate_authorities` and a defined list of CAs.
85
- config :ssl_verify_mode, :validate => ["none", "peer", "force_peer"], :default => "none"
108
+ config :ssl_verify_mode, :validate => ["none", "peer", "force_peer"], :default => "none", :deprecated => "Set 'ssl_client_authentication' instead."
86
109
 
87
110
  # Time in milliseconds for an incomplete ssl handshake to timeout
88
111
  config :ssl_handshake_timeout, :validate => :number, :default => 10000
@@ -118,10 +141,13 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
118
141
  # Deprecated options
119
142
 
120
143
  # The JKS keystore to validate the client's certificates
121
- config :keystore, :validate => :path, :deprecated => "Set 'ssl_certificate' and 'ssl_key' instead."
122
- config :keystore_password, :validate => :password, :deprecated => "Set 'ssl_key_passphrase' instead."
144
+ config :keystore, :validate => :path, :deprecated => "Set 'ssl_keystore_path' instead."
145
+
146
+ # The JKS keystore password
147
+ config :keystore_password, :validate => :password, :deprecated => "Set 'ssl_keystore_password' instead."
148
+
149
+ config :verify_mode, :validate => ['none', 'peer', 'force_peer'], :default => 'none', :deprecated => "Set 'ssl_client_authentication' instead."
123
150
 
124
- config :verify_mode, :validate => ['none', 'peer', 'force_peer'], :default => 'none', :deprecated => "Set 'ssl_verify_mode' instead."
125
151
  config :cipher_suites, :validate => :array, :default => [], :deprecated => "Set 'ssl_cipher_suites' instead."
126
152
 
127
153
  # The minimum TLS version allowed for the encrypted connections. The value must be one of the following:
@@ -134,9 +160,36 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
134
160
 
135
161
  attr_reader :codecs
136
162
 
163
+ NON_PREFIXED_SSL_CONFIGS = Set[
164
+ 'keystore',
165
+ 'keystore_password',
166
+ 'verify_mode',
167
+ 'tls_min_version',
168
+ 'tls_max_version',
169
+ 'cipher_suites',
170
+ ].freeze
171
+
172
+ SSL_CLIENT_AUTH_NONE = 'none'.freeze
173
+ SSL_CLIENT_AUTH_OPTIONAL = 'optional'.freeze
174
+ SSL_CLIENT_AUTH_REQUIRED = 'required'.freeze
175
+
176
+ SSL_VERIFY_MODE_TO_CLIENT_AUTHENTICATION_MAP = {
177
+ 'none' => SSL_CLIENT_AUTH_NONE,
178
+ 'peer' => SSL_CLIENT_AUTH_OPTIONAL,
179
+ 'force_peer' => SSL_CLIENT_AUTH_REQUIRED
180
+ }.freeze
181
+
182
+ private_constant :SSL_CLIENT_AUTH_NONE
183
+ private_constant :SSL_CLIENT_AUTH_OPTIONAL
184
+ private_constant :SSL_CLIENT_AUTH_REQUIRED
185
+ private_constant :NON_PREFIXED_SSL_CONFIGS
186
+ private_constant :SSL_VERIFY_MODE_TO_CLIENT_AUTHENTICATION_MAP
187
+
137
188
  public
138
189
  def register
139
190
 
191
+ setup_ssl_params!
192
+
140
193
  validate_ssl_settings!
141
194
 
142
195
  if @user && @password
@@ -234,78 +287,123 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
234
287
  end
235
288
 
236
289
  def validate_ssl_settings!
237
- if !@ssl
238
- @logger.warn("SSL Certificate will not be used") if @ssl_certificate
239
- @logger.warn("SSL Key will not be used") if @ssl_key
240
- @logger.warn("SSL Java Key Store will not be used") if @keystore
241
- return # code bellow assumes `ssl => true`
290
+ ssl_config_name = original_params.include?('ssl') ? 'ssl' : 'ssl_enabled'
291
+
292
+ unless @ssl_enabled
293
+ ignored_ssl_settings = original_params.select { |k| k != 'ssl_enabled' && k.start_with?('ssl_') || NON_PREFIXED_SSL_CONFIGS.include?(k) }
294
+ @logger.warn("Configured SSL settings are not used when `#{ssl_config_name}` is set to `false`: #{ignored_ssl_settings.keys}") if ignored_ssl_settings.any?
295
+ return # code bellow assumes `ssl_enabled => true`
242
296
  end
243
297
 
244
- if !(ssl_key_configured? || ssl_jks_configured?)
245
- raise LogStash::ConfigurationError, "Certificate or JKS must be configured"
298
+ if @ssl_certificate && !@ssl_key
299
+ raise LogStash::ConfigurationError, "Using an `ssl_certificate` requires an `ssl_key`"
300
+ elsif @ssl_key && !@ssl_certificate
301
+ raise LogStash::ConfigurationError, 'An `ssl_certificate` is required when using an `ssl_key`'
246
302
  end
247
303
 
248
- if original_params.key?("verify_mode") && original_params.key?("ssl_verify_mode")
249
- raise LogStash::ConfigurationError, "Both `ssl_verify_mode` and (deprecated) `verify_mode` were set. Use only `ssl_verify_mode`."
250
- elsif original_params.key?("verify_mode")
251
- @ssl_verify_mode_final = @verify_mode
252
- else
253
- @ssl_verify_mode_final = @ssl_verify_mode
304
+ unless ssl_key_configured? || ssl_jks_configured?
305
+ raise LogStash::ConfigurationError, "Either an `ssl_certificate` or `ssl_keystore_path` is required when SSL is enabled `#{ssl_config_name} => true`"
254
306
  end
255
307
 
256
- if original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites')
257
- raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`."
258
- elsif original_params.key?('cipher_suites')
259
- @ssl_cipher_suites_final = @cipher_suites
260
- else
261
- @ssl_cipher_suites_final = @ssl_cipher_suites
308
+ if require_certificate_authorities? && !certificate_authorities_configured?
309
+ config_name, optional, required = provided_client_authentication_config([SSL_CLIENT_AUTH_OPTIONAL, SSL_CLIENT_AUTH_REQUIRED])
310
+ raise LogStash::ConfigurationError, "Using `#{config_name}` set to `#{optional}` or `#{required}`, requires the configuration of `ssl_certificate_authorities`"
262
311
  end
263
312
 
264
- if original_params.key?('tls_min_version') && original_params.key?('ssl_supported_protocols')
265
- raise LogStash::ConfigurationError, "Both `ssl_supported_protocols` and (deprecated) `tls_min_ciphers` were set. Use only `ssl_supported_protocols`."
266
- elsif original_params.key?('tls_max_version') && original_params.key?('ssl_supported_protocols')
267
- raise LogStash::ConfigurationError, "Both `ssl_supported_protocols` and (deprecated) `tls_max_ciphers` were set. Use only `ssl_supported_protocols`."
268
- else
269
- if original_params.key?('tls_min_version') || original_params.key?('tls_max_version')
270
- @ssl_supported_protocols_final = TLS.get_supported(tls_min_version..tls_max_version).map(&:name)
271
- else
272
- @ssl_supported_protocols_final = @ssl_supported_protocols
313
+ if !require_certificate_authorities? && certificate_authorities_configured?
314
+ config_name, optional, required = provided_client_authentication_config([SSL_CLIENT_AUTH_OPTIONAL, SSL_CLIENT_AUTH_REQUIRED])
315
+ raise LogStash::ConfigurationError, "The configuration of `ssl_certificate_authorities` requires setting `#{config_name}` to `#{optional}` or '#{required}'"
316
+ end
317
+ end
318
+
319
+ def setup_ssl_params!
320
+ @ssl_enabled = normalize_config(:ssl_enabled) do |normalizer|
321
+ normalizer.with_deprecated_alias(:ssl)
322
+ end
323
+
324
+ @ssl_cipher_suites = normalize_config(:ssl_cipher_suites) do |normalizer|
325
+ normalizer.with_deprecated_alias(:cipher_suites)
326
+ end
327
+
328
+ @ssl_supported_protocols = normalize_config(:ssl_supported_protocols) do |normalizer|
329
+ normalizer.with_deprecated_mapping(:tls_min_version, :tls_max_version) do |tls_min_version, tls_max_version|
330
+ TLS.get_supported(tls_min_version..tls_max_version).map(&:name)
331
+ end
332
+ end
333
+
334
+ @ssl_client_authentication = normalize_config(:ssl_client_authentication) do |normalizer|
335
+ normalizer.with_deprecated_mapping(:verify_mode, :ssl_verify_mode) do |verify_mode, ssl_verify_mode|
336
+ normalize_ssl_client_authentication_value!(verify_mode, ssl_verify_mode)
273
337
  end
274
338
  end
275
339
 
276
- if require_certificate_authorities? && !client_authentication?
277
- raise LogStash::ConfigurationError, "Using `ssl_verify_mode` (or `verify_mode`) set to PEER or FORCE_PEER, requires the configuration of `ssl_certificate_authorities`"
278
- elsif !require_certificate_authorities? && client_authentication?
279
- raise LogStash::ConfigurationError, "The configuration of `ssl_certificate_authorities` requires setting `ssl_verify_mode` (or `verify_mode`) to PEER or FORCE_PEER"
340
+ @ssl_keystore_path = normalize_config(:ssl_keystore_path) do |normalizer|
341
+ normalizer.with_deprecated_alias(:keystore)
342
+ end
343
+
344
+ @ssl_keystore_password = normalize_config(:ssl_keystore_password) do |normalizer|
345
+ normalizer.with_deprecated_alias(:keystore_password)
280
346
  end
347
+
348
+ params['ssl_enabled'] = @ssl_enabled unless @ssl_enabled.nil?
349
+ params['ssl_cipher_suites'] = @ssl_cipher_suites unless @ssl_cipher_suites.nil?
350
+ params['ssl_supported_protocols'] = @ssl_supported_protocols unless @ssl_supported_protocols.nil?
351
+ params['ssl_client_authentication'] = @ssl_client_authentication unless @ssl_client_authentication.nil?
352
+ params['ssl_keystore_path'] = @ssl_keystore_path unless @ssl_keystore_path.nil?
353
+ params['ssl_keystore_password'] = @ssl_keystore_password unless @ssl_keystore_password.nil?
354
+ end
355
+
356
+ def normalize_ssl_client_authentication_value!(verify_mode, ssl_verify_mode)
357
+ verify_mode_explicitly_set = original_params.key?("verify_mode")
358
+
359
+ if verify_mode_explicitly_set && original_params.key?("ssl_verify_mode")
360
+ raise LogStash::ConfigurationError, "Both (deprecated) `ssl_verify_mode` and `verify_mode` were set. Use only `ssl_verify_mode`"
361
+ end
362
+
363
+ deprecated_value = (verify_mode_explicitly_set ? verify_mode : ssl_verify_mode).downcase
364
+ SSL_VERIFY_MODE_TO_CLIENT_AUTHENTICATION_MAP[deprecated_value]
281
365
  end
282
366
 
283
367
  def create_http_server(message_handler)
284
368
  org.logstash.plugins.inputs.http.NettyHttpServer.new(
285
- @host, @port, message_handler, build_ssl_params(), @threads, @max_pending_requests, @max_content_length, @response_code)
369
+ @host, @port, message_handler, build_ssl_params, @threads, @max_pending_requests, @max_content_length, @response_code)
286
370
  end
287
371
 
288
372
  def build_ssl_params
289
- return nil unless @ssl
373
+ return nil unless @ssl_enabled
290
374
 
291
- if @keystore && @keystore_password
292
- ssl_builder = org.logstash.plugins.inputs.http.util.JksSslBuilder.new(@keystore, @keystore_password.value)
375
+ if @ssl_keystore_path && @ssl_keystore_password
376
+ ssl_builder = org.logstash.plugins.inputs.http.util.JksSslBuilder.new(@ssl_keystore_path, @ssl_keystore_password.value)
293
377
  else
294
- begin
295
- ssl_builder = org.logstash.plugins.inputs.http.util.SslSimpleBuilder
296
- .new(@ssl_certificate, @ssl_key, @ssl_key_passphrase.nil? ? nil : @ssl_key_passphrase.value)
297
- .setCipherSuites(normalized_cipher_suites)
298
- rescue java.lang.IllegalArgumentException => e
299
- @logger.error("SSL configuration invalid", error_details(e))
300
- raise LogStash::ConfigurationError, e
301
- end
378
+ ssl_builder = new_ssl_simple_builder
379
+ end
380
+
381
+ new_ssl_handshake_provider(ssl_builder)
382
+ end
383
+
384
+ def new_ssl_simple_builder
385
+ passphrase = @ssl_key_passphrase.nil? ? nil : @ssl_key_passphrase.value
386
+ begin
387
+ ssl_context_builder = SslSimpleBuilder.new(@ssl_certificate, @ssl_key, passphrase)
388
+ .setProtocols(@ssl_supported_protocols)
389
+ .setCipherSuites(normalized_cipher_suites)
302
390
 
303
- if client_authentication?
304
- ssl_builder.setCertificateAuthorities(@ssl_certificate_authorities)
391
+ if client_authentication_enabled?
392
+ ssl_context_builder.setClientAuthentication(ssl_simple_builder_verify_mode, @ssl_certificate_authorities)
305
393
  end
394
+
395
+ ssl_context_builder
396
+ rescue java.lang.IllegalArgumentException => e
397
+ @logger.error("SSL configuration invalid", error_details(e))
398
+ raise LogStash::ConfigurationError, e
306
399
  end
400
+ end
307
401
 
308
- new_ssl_handshake_provider(ssl_builder)
402
+ def ssl_simple_builder_verify_mode
403
+ return SslSimpleBuilder::SslClientVerifyMode::OPTIONAL if client_authentication_optional?
404
+ return SslSimpleBuilder::SslClientVerifyMode::REQUIRED if client_authentication_required?
405
+ return SslSimpleBuilder::SslClientVerifyMode::NONE if client_authentication_none?
406
+ raise LogStash::ConfigurationError, "Invalid `ssl_client_authentication` value #{@ssl_client_authentication}"
309
407
  end
310
408
 
311
409
  def ssl_key_configured?
@@ -313,30 +411,52 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
313
411
  end
314
412
 
315
413
  def ssl_jks_configured?
316
- !!(@keystore && @keystore_password)
414
+ !!(@ssl_keystore_path && @ssl_keystore_password)
317
415
  end
318
416
 
319
- def client_authentication?
320
- @ssl_certificate_authorities && @ssl_certificate_authorities.size > 0
417
+ def client_authentication_enabled?
418
+ client_authentication_optional? || client_authentication_required?
321
419
  end
322
420
 
323
421
  def require_certificate_authorities?
324
- @ssl_verify_mode_final == "force_peer" || @ssl_verify_mode_final == "peer"
422
+ client_authentication_required? || client_authentication_optional?
423
+ end
424
+
425
+ def certificate_authorities_configured?
426
+ @ssl_certificate_authorities && @ssl_certificate_authorities.size > 0
427
+ end
428
+
429
+ def client_authentication_required?
430
+ @ssl_client_authentication && @ssl_client_authentication.downcase == SSL_CLIENT_AUTH_REQUIRED
431
+ end
432
+
433
+ def client_authentication_none?
434
+ @ssl_client_authentication && @ssl_client_authentication.downcase == SSL_CLIENT_AUTH_NONE
435
+ end
436
+
437
+ def client_authentication_optional?
438
+ @ssl_client_authentication && @ssl_client_authentication.downcase == SSL_CLIENT_AUTH_OPTIONAL
439
+ end
440
+
441
+ def provided_client_authentication_config(values = [@ssl_client_authentication])
442
+ if original_params.include?('ssl_verify_mode')
443
+ ['ssl_verify_mode', *values.map { |v| SSL_VERIFY_MODE_TO_CLIENT_AUTHENTICATION_MAP.key(v) }]
444
+ elsif original_params.include?('verify_mode')
445
+ ['verify_mode', *values.map { |v| SSL_VERIFY_MODE_TO_CLIENT_AUTHENTICATION_MAP.key(v) }]
446
+ else
447
+ ['ssl_client_authentication', *values]
448
+ end
325
449
  end
326
450
 
327
451
  private
328
452
 
329
453
  def normalized_cipher_suites
330
- @ssl_cipher_suites_final.map(&:upcase)
454
+ @ssl_cipher_suites.map(&:upcase)
331
455
  end
332
456
 
333
457
  def new_ssl_handshake_provider(ssl_builder)
334
458
  begin
335
- ssl_handler_provider = org.logstash.plugins.inputs.http.util.SslHandlerProvider.new(ssl_builder.build())
336
- ssl_handler_provider.setVerifyMode(@ssl_verify_mode_final.upcase)
337
- ssl_handler_provider.setProtocols(@ssl_supported_protocols_final)
338
- ssl_handler_provider.setHandshakeTimeoutMilliseconds(@ssl_handshake_timeout)
339
- ssl_handler_provider
459
+ org.logstash.plugins.inputs.http.util.SslHandlerProvider.new(ssl_builder.build(), @ssl_handshake_timeout)
340
460
  rescue java.lang.IllegalArgumentException => e
341
461
  @logger.error("SSL configuration invalid", error_details(e))
342
462
  raise LogStash::ConfigurationError, e
@@ -1,5 +1,11 @@
1
1
  # AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.
2
2
 
3
3
  require 'jar_dependencies'
4
- require_jar('io.netty', 'netty-all', '4.1.65.Final')
5
- require_jar('org.logstash.plugins.input.http', 'logstash-input-http', '3.6.0')
4
+ require_jar('io.netty', 'netty-buffer', '4.1.87.Final')
5
+ require_jar('io.netty', 'netty-codec', '4.1.87.Final')
6
+ require_jar('io.netty', 'netty-codec-http', '4.1.87.Final')
7
+ require_jar('io.netty', 'netty-common', '4.1.87.Final')
8
+ require_jar('io.netty', 'netty-transport', '4.1.87.Final')
9
+ require_jar('io.netty', 'netty-handler', '4.1.87.Final')
10
+ require_jar('io.netty', 'netty-transport-native-unix-common', '4.1.87.Final')
11
+ require_jar('org.logstash.plugins.input.http', 'logstash-input-http', '3.7.0')
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_runtime_dependency 'logstash-codec-plain'
25
25
  s.add_runtime_dependency 'jar-dependencies', '~> 0.3', '>= 0.3.4'
26
26
  s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.2'
27
+ s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'
27
28
 
28
29
  s.add_development_dependency 'logstash-devutils'
29
30
  s.add_development_dependency 'logstash-codec-json'
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ CERTS_DIR = File.expand_path('../fixtures/certs/generated', File.dirname(__FILE__))
3
+
4
+ def certificate_path(filename)
5
+ File.join(CERTS_DIR, filename)
6
+ end
@@ -7,6 +7,7 @@ require "stud/temporary"
7
7
  require "zlib"
8
8
  require "stringio"
9
9
  require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
10
+ require 'inputs/helpers'
10
11
 
11
12
  java_import "io.netty.handler.ssl.util.SelfSignedCertificate"
12
13
 
@@ -165,22 +166,20 @@ describe LogStash::Inputs::Http do
165
166
 
166
167
  let(:url) { super().sub('http://', 'https://') }
167
168
 
168
- certs_dir = File.expand_path('../fixtures/certs/generated', File.dirname(__FILE__))
169
-
170
169
  let(:config) do
171
- super().merge 'ssl' => true,
172
- 'ssl_certificate_authorities' => [ File.join(certs_dir, 'root.crt') ],
173
- 'ssl_certificate' => File.join(certs_dir, 'server_from_root.crt'),
174
- 'ssl_key' => File.join(certs_dir, 'server_from_root.key.pkcs8'),
175
- 'ssl_verify_mode' => 'peer'
170
+ super().merge 'ssl_enabled' => true,
171
+ 'ssl_certificate_authorities' => [certificate_path('root.crt')],
172
+ 'ssl_certificate' => certificate_path( 'server_from_root.crt'),
173
+ 'ssl_key' => certificate_path( 'server_from_root.key.pkcs8'),
174
+ 'ssl_client_authentication' => 'optional'
176
175
  end
177
176
 
178
177
  let(:client_options) do
179
178
  super().merge ssl: {
180
179
  verify: false,
181
- ca_file: File.join(certs_dir, 'root.crt'),
182
- client_cert: File.join(certs_dir, 'client_from_root.crt'),
183
- client_key: File.join(certs_dir, 'client_from_root.key.pkcs8'),
180
+ ca_file: certificate_path( 'root.crt'),
181
+ client_cert: certificate_path( 'client_from_root.crt'),
182
+ client_key: certificate_path( 'client_from_root.key.pkcs8'),
184
183
  }
185
184
  end
186
185
 
@@ -538,15 +537,27 @@ describe LogStash::Inputs::Http do
538
537
  end
539
538
  end
540
539
 
541
- context "with :ssl => false" do
542
- subject { LogStash::Inputs::Http.new("port" => port, "ssl" => false) }
540
+ context "with :ssl_enabled => false" do
541
+ let(:config) { {"port" => port, "ssl_enabled" => false} }
542
+
543
543
  it "should not raise exception" do
544
544
  expect { subject.register }.to_not raise_exception
545
545
  end
546
+
547
+ context "and `ssl_` settings provided" do
548
+ let(:ssc) { SelfSignedCertificate.new }
549
+ let(:config) { { "port" => 0, "ssl_enabled" => false, "ssl_certificate" => ssc.certificate.path, "ssl_client_authentication" => "none", "cipher_suites" => ["TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"] } }
550
+
551
+ it "should warn about not using the configs" do
552
+ expect(subject.logger).to receive(:warn).with(/^Configured SSL settings are not used when `ssl_enabled` is set to `false`: \[("ssl_certificate"(,\s)?|"ssl_client_authentication"(,\s)?|"cipher_suites"(,\s)?)*\]$/)
553
+ subject.register
554
+ end
555
+ end
546
556
  end
547
- context "with :ssl => true" do
557
+
558
+ context "with :ssl_enabled => true" do
548
559
  context "without :ssl_certificate" do
549
- subject { LogStash::Inputs::Http.new("port" => port, "ssl" => true) }
560
+ subject { LogStash::Inputs::Http.new("port" => port, "ssl_enabled" => true) }
550
561
  it "should raise exception" do
551
562
  expect { subject.register }.to raise_exception(LogStash::ConfigurationError)
552
563
  end
@@ -563,7 +574,7 @@ describe LogStash::Inputs::Http do
563
574
  let(:ssl_key) { ssc.private_key }
564
575
 
565
576
  let(:config) do
566
- { "port" => port, "ssl" => true, "ssl_certificate" => ssl_certificate.path, "ssl_key" => ssl_key.path }
577
+ { "port" => port, "ssl_enabled" => true, "ssl_certificate" => ssl_certificate.path, "ssl_key" => ssl_key.path }
567
578
  end
568
579
 
569
580
  after(:each) { ssc.delete }
@@ -575,46 +586,37 @@ describe LogStash::Inputs::Http do
575
586
  end
576
587
 
577
588
  context "with ssl_verify_mode = none" do
578
- subject { LogStash::Inputs::Http.new(config.merge("ssl_verify_mode" => "none")) }
589
+ subject { LogStash::Inputs::Http.new(config.merge("ssl_client_authentication" => "none")) }
579
590
 
580
591
  it "should not raise exception" do
581
592
  expect { subject.register }.to_not raise_exception
582
593
  end
583
594
  end
584
- ["peer", "force_peer"].each do |verify_mode|
585
- context "with ssl_verify_mode = #{verify_mode}" do
586
- subject { LogStash::Inputs::Http.new("port" => port, "ssl" => true,
587
- "ssl_certificate" => ssl_certificate.path,
588
- "ssl_certificate_authorities" => ssl_certificate.path,
589
- "ssl_key" => ssl_key.path,
590
- "ssl_verify_mode" => verify_mode
591
- ) }
592
- it "should not raise exception" do
593
- expect { subject.register }.to_not raise_exception
595
+ ["ssl_verify_mode", "verify_mode"].each do |config_name|
596
+ ["peer", "force_peer"].each do |verify_mode|
597
+ context "with deprecated #{config_name} = #{verify_mode}" do
598
+ subject { LogStash::Inputs::Http.new("port" => port,
599
+ "ssl_enabled" => true,
600
+ "ssl_certificate" => ssl_certificate.path,
601
+ "ssl_certificate_authorities" => ssl_certificate.path,
602
+ "ssl_key" => ssl_key.path,
603
+ config_name => verify_mode
604
+ ) }
605
+ it "should not raise exception" do
606
+ expect { subject.register }.to_not raise_exception
607
+ end
594
608
  end
595
609
  end
596
610
  end
597
- context "with verify_mode = none" do
598
- subject { LogStash::Inputs::Http.new(config.merge("verify_mode" => "none")) }
611
+ ["ssl_verify_mode", "verify_mode"].each do |config_name|
612
+ context "with deprecated #{config_name} = none" do
613
+ subject { LogStash::Inputs::Http.new(config.merge(config_name => "none")) }
599
614
 
600
- it "should not raise exception" do
601
- expect { subject.register }.to_not raise_exception
602
- end
603
- end
604
- ["peer", "force_peer"].each do |verify_mode|
605
- context "with verify_mode = #{verify_mode}" do
606
- subject { LogStash::Inputs::Http.new("port" => port, "ssl" => true,
607
- "ssl_certificate" => ssl_certificate.path,
608
- "ssl_certificate_authorities" => ssl_certificate.path,
609
- "ssl_key" => ssl_key.path,
610
- "verify_mode" => verify_mode
611
- ) }
612
615
  it "should not raise exception" do
613
616
  expect { subject.register }.to_not raise_exception
614
617
  end
615
618
  end
616
619
  end
617
-
618
620
  context "with invalid ssl certificate" do
619
621
  before do
620
622
  cert = File.readlines path = config["ssl_certificate"]
@@ -646,7 +648,7 @@ describe LogStash::Inputs::Http do
646
648
 
647
649
  context "with invalid ssl certificate_authorities" do
648
650
  let(:config) do
649
- super().merge("ssl_verify_mode" => "peer", "ssl_certificate_authorities" => [ ssc.certificate.path, ssc.private_key.path ])
651
+ super().merge("ssl_client_authentication" => "optional", "ssl_certificate_authorities" => [ ssc.certificate.path, ssc.private_key.path ])
650
652
  end
651
653
 
652
654
  it "should raise a cert error" do
@@ -662,13 +664,33 @@ describe LogStash::Inputs::Http do
662
664
  end
663
665
  end
664
666
 
665
- context "with both verify_mode options set" do
667
+ context "with both verify_mode and ssl_verify_mode options set" do
666
668
  let(:config) do
667
- super().merge('ssl_verify_mode' => 'peer', 'verify_mode' => 'none')
669
+ super().merge('verify_mode' => 'none', 'ssl_verify_mode' => 'none')
668
670
  end
669
671
 
670
672
  it "should raise a configuration error" do
671
- expect { subject.register }.to raise_error LogStash::ConfigurationError, /Use only .?ssl_verify_mode.?/i
673
+ expect { subject.register }.to raise_error LogStash::ConfigurationError, /Use only .?ssl_verify_mode`.?/i
674
+ end
675
+ end
676
+
677
+ context "with both ssl_client_authentication and ssl_verify_mode options set" do
678
+ let(:config) do
679
+ super().merge('ssl_client_authentication' => 'optional', 'ssl_verify_mode' => 'none')
680
+ end
681
+
682
+ it "should raise a configuration error" do
683
+ expect { subject.register }.to raise_error LogStash::ConfigurationError, /Use only .?ssl_client_authentication.?/i
684
+ end
685
+ end
686
+
687
+ context "with both ssl_client_authentication and verify_mode options set" do
688
+ let(:config) do
689
+ super().merge('ssl_client_authentication' => 'optional', 'verify_mode' => 'none')
690
+ end
691
+
692
+ it "should raise a configuration error" do
693
+ expect { subject.register }.to raise_error LogStash::ConfigurationError, /Use only .?ssl_client_authentication.?/i
672
694
  end
673
695
  end
674
696
 
@@ -703,6 +725,101 @@ describe LogStash::Inputs::Http do
703
725
  end
704
726
  end
705
727
 
728
+ context "with both ssl and ssl_enabled set" do
729
+ let(:config) do
730
+ super().merge('ssl' => true, 'ssl_enabled' => true )
731
+ end
732
+
733
+ it "should raise a configuration error" do
734
+ expect { subject.register }.to raise_error LogStash::ConfigurationError, /Use only .?ssl_enabled.?/i
735
+ end
736
+ end
737
+
738
+ context "with ssl_client_authentication" do
739
+ context "normalized from ssl_verify_mode 'none'" do
740
+ let(:config) { super().merge("ssl_verify_mode" => "none") }
741
+
742
+ it "should transform the value to 'none'" do
743
+ subject.register
744
+ expect(subject.params).to match hash_including("ssl_client_authentication" => "none")
745
+ expect(subject.instance_variable_get(:@ssl_client_authentication)).to eql("none")
746
+ end
747
+
748
+ context "and ssl_certificate_authorities is set" do
749
+ let(:config) { super().merge("ssl_certificate_authorities" => [certificate_path( 'root.crt')]) }
750
+ it "raise a configuration error" do
751
+ expect { subject.register }.to raise_error(LogStash::ConfigurationError, "The configuration of `ssl_certificate_authorities` requires setting `ssl_verify_mode` to `peer` or 'force_peer'")
752
+ end
753
+ end
754
+ end
755
+
756
+ [%w[peer optional], %w[force_peer required]].each do |ssl_verify_mode, ssl_client_authentication|
757
+ context "normalized from ssl_verify_mode '#{ssl_verify_mode}'" do
758
+ let(:config) { super().merge("ssl_verify_mode" => ssl_verify_mode, "ssl_certificate_authorities" => [certificate_path( 'root.crt')]) }
759
+
760
+ it "should transform the value to '#{ssl_client_authentication}'" do
761
+ subject.register
762
+ expect(subject.params).to match hash_including("ssl_client_authentication" => ssl_client_authentication)
763
+ expect(subject.instance_variable_get(:@ssl_client_authentication)).to eql(ssl_client_authentication)
764
+ end
765
+
766
+ context "with no ssl_certificate_authorities set " do
767
+ let(:config) { super().reject { |key| "ssl_certificate_authorities".eql?(key) } }
768
+ it "raise a configuration error" do
769
+ expect {subject.register}.to raise_error(LogStash::ConfigurationError, "Using `ssl_verify_mode` set to `peer` or `force_peer`, requires the configuration of `ssl_certificate_authorities`")
770
+ end
771
+ end
772
+ end
773
+ end
774
+
775
+ context "configured to 'none'" do
776
+ let(:config) { super().merge("ssl_client_authentication" => "none") }
777
+
778
+ it "doesn't raise an error when certificate_authorities is not set" do
779
+ expect {subject.register}.to_not raise_error
780
+ end
781
+
782
+ context "with certificate_authorities set" do
783
+ let(:config) { super().merge("ssl_certificate_authorities" => [certificate_path( 'root.crt')]) }
784
+
785
+ it "raise a configuration error" do
786
+ expect {subject.register}.to raise_error(LogStash::ConfigurationError, "The configuration of `ssl_certificate_authorities` requires setting `ssl_client_authentication` to `optional` or 'required'")
787
+ end
788
+ end
789
+ end
790
+
791
+ context "configured to 'required'" do
792
+ let(:config) { super().merge("ssl_client_authentication" => "required") }
793
+
794
+ it "raise a ConfigurationError when certificate_authorities is not set" do
795
+ expect {subject.register}.to raise_error(LogStash::ConfigurationError, "Using `ssl_client_authentication` set to `optional` or `required`, requires the configuration of `ssl_certificate_authorities`")
796
+ end
797
+
798
+ context "with ssl_certificate_authorities set" do
799
+ let(:config) { super().merge("ssl_certificate_authorities" => [certificate_path( 'root.crt')]) }
800
+
801
+ it "doesn't raise a configuration error" do
802
+ expect {subject.register}.not_to raise_error
803
+ end
804
+ end
805
+ end
806
+
807
+ context "configured to 'optional'" do
808
+ let(:config) { super().merge("ssl_client_authentication" => "optional") }
809
+
810
+ it "raise a ConfigurationError when certificate_authorities is not set" do
811
+ expect {subject.register}.to raise_error(LogStash::ConfigurationError, "Using `ssl_client_authentication` set to `optional` or `required`, requires the configuration of `ssl_certificate_authorities`")
812
+ end
813
+
814
+ context "with certificate_authorities set" do
815
+ let(:config) { super().merge("ssl_certificate_authorities" => [certificate_path( 'root.crt')]) }
816
+
817
+ it "doesn't raise a configuration error" do
818
+ expect {subject.register}.not_to raise_error
819
+ end
820
+ end
821
+ end
822
+ end
706
823
  end
707
824
  end
708
825
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-19 00:00:00.000000000 Z
11
+ date: 2023-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +78,20 @@ dependencies:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: '1.2'
81
+ - !ruby/object:Gem::Dependency
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '1.0'
87
+ name: logstash-mixin-normalize_config_support
88
+ prerelease: false
89
+ type: :runtime
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.0'
81
95
  - !ruby/object:Gem::Dependency
82
96
  requirement: !ruby/object:Gem::Requirement
83
97
  requirements:
@@ -171,9 +185,16 @@ files:
171
185
  - spec/fixtures/certs/generated/server_from_root.key
172
186
  - spec/fixtures/certs/generated/server_from_root.key.pkcs8
173
187
  - spec/fixtures/certs/openssl.cnf
188
+ - spec/inputs/helpers.rb
174
189
  - spec/inputs/http_spec.rb
175
- - vendor/jar-dependencies/io/netty/netty-all/4.1.65.Final/netty-all-4.1.65.Final.jar
176
- - vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/3.6.0/logstash-input-http-3.6.0.jar
190
+ - vendor/jar-dependencies/io/netty/netty-buffer/4.1.87.Final/netty-buffer-4.1.87.Final.jar
191
+ - vendor/jar-dependencies/io/netty/netty-codec-http/4.1.87.Final/netty-codec-http-4.1.87.Final.jar
192
+ - vendor/jar-dependencies/io/netty/netty-codec/4.1.87.Final/netty-codec-4.1.87.Final.jar
193
+ - vendor/jar-dependencies/io/netty/netty-common/4.1.87.Final/netty-common-4.1.87.Final.jar
194
+ - vendor/jar-dependencies/io/netty/netty-handler/4.1.87.Final/netty-handler-4.1.87.Final.jar
195
+ - vendor/jar-dependencies/io/netty/netty-transport-native-unix-common/4.1.87.Final/netty-transport-native-unix-common-4.1.87.Final.jar
196
+ - vendor/jar-dependencies/io/netty/netty-transport/4.1.87.Final/netty-transport-4.1.87.Final.jar
197
+ - vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/3.7.0/logstash-input-http-3.7.0.jar
177
198
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
178
199
  licenses:
179
200
  - Apache License (2.0)
@@ -215,4 +236,5 @@ test_files:
215
236
  - spec/fixtures/certs/generated/server_from_root.key
216
237
  - spec/fixtures/certs/generated/server_from_root.key.pkcs8
217
238
  - spec/fixtures/certs/openssl.cnf
239
+ - spec/inputs/helpers.rb
218
240
  - spec/inputs/http_spec.rb