@@ -30,6 +30,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
30
30
require "logstash/inputs/http/tls"
31
31
32
32
java_import "io.netty.handler.codec.http.HttpUtil"
33
+ java_import 'org.logstash.plugins.inputs.http.util.SslSimpleBuilder'
33
34
34
35
config_name "http"
35
36
@@ -86,16 +87,11 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
86
87
# Time in milliseconds for an incomplete ssl handshake to timeout
87
88
config :ssl_handshake_timeout , :validate => :number , :default => 10000
88
89
89
- # The minimum TLS version allowed for the encrypted connections. The value must be one of the following:
90
- # 1.0 for TLS 1.0, 1.1 for TLS 1.1, 1.2 for TLS 1.2, 1.3 for TLS 1.3
91
- config :tls_min_version , :validate => :number , :default => TLS . min . version
92
-
93
- # The maximum TLS version allowed for the encrypted connections. The value must be the one of the following:
94
- # 1.0 for TLS 1.0, 1.1 for TLS 1.1, 1.2 for TLS 1.2, 1.3 for TLS 1.3
95
- config :tls_max_version , :validate => :number , :default => TLS . max . version
96
-
97
90
# The list of ciphers suite to use, listed by priorities.
98
- config :cipher_suites , :validate => :array , :default => org . logstash . plugins . inputs . http . util . SslSimpleBuilder . getDefaultCiphers
91
+ config :ssl_cipher_suites , :validate => SslSimpleBuilder ::SUPPORTED_CIPHERS . to_a ,
92
+ :default => SslSimpleBuilder . getDefaultCiphers , :list => true
93
+
94
+ config :ssl_supported_protocols , :validate => [ 'TLSv1.1' , 'TLSv1.2' , 'TLSv1.3' ] , :default => [ 'TLSv1.2' , 'TLSv1.3' ] , :list => true
99
95
100
96
# Apply specific codecs for specific content types.
101
97
# The default codec will be applied only after this list is checked
@@ -118,14 +114,23 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
118
114
config :max_content_length , :validate => :number , :required => false , :default => 100 * 1024 * 1024
119
115
120
116
config :response_code , :validate => [ 200 , 201 , 202 , 204 ] , :default => 200
117
+
121
118
# Deprecated options
122
119
123
120
# The JKS keystore to validate the client's certificates
124
121
config :keystore , :validate => :path , :deprecated => "Set 'ssl_certificate' and 'ssl_key' instead."
125
122
config :keystore_password , :validate => :password , :deprecated => "Set 'ssl_key_passphrase' instead."
126
123
127
- config :verify_mode , :validate => [ 'none' , 'peer' , 'force_peer' ] , :default => 'none' ,
128
- :deprecated => "Set 'ssl_verify_mode' instead."
124
+ config :verify_mode , :validate => [ 'none' , 'peer' , 'force_peer' ] , :default => 'none' , :deprecated => "Set 'ssl_verify_mode' instead."
125
+ config :cipher_suites , :validate => :array , :default => [ ] , :deprecated => "Set 'ssl_cipher_suites' instead."
126
+
127
+ # The minimum TLS version allowed for the encrypted connections. The value must be one of the following:
128
+ # 1.0 for TLS 1.0, 1.1 for TLS 1.1, 1.2 for TLS 1.2, 1.3 for TLS 1.3
129
+ config :tls_min_version , :validate => :number , :default => TLS . min . version , :deprecated => "Set 'ssl_supported_protocols' instead."
130
+
131
+ # The maximum TLS version allowed for the encrypted connections. The value must be the one of the following:
132
+ # 1.0 for TLS 1.0, 1.1 for TLS 1.1, 1.2 for TLS 1.2, 1.3 for TLS 1.3
133
+ config :tls_max_version , :validate => :number , :default => TLS . max . version , :deprecated => "Set 'ssl_supported_protocols' instead."
129
134
130
135
attr_reader :codecs
131
136
@@ -233,24 +238,45 @@ def validate_ssl_settings!
233
238
@logger . warn ( "SSL Certificate will not be used" ) if @ssl_certificate
234
239
@logger . warn ( "SSL Key will not be used" ) if @ssl_key
235
240
@logger . warn ( "SSL Java Key Store will not be used" ) if @keystore
236
- elsif !( ssl_key_configured? || ssl_jks_configured? )
241
+ return # code bellow assumes `ssl => true`
242
+ end
243
+
244
+ if !( ssl_key_configured? || ssl_jks_configured? )
237
245
raise LogStash ::ConfigurationError , "Certificate or JKS must be configured"
238
246
end
239
247
240
- if @ssl && ( original_params . key? ( "verify_mode" ) && original_params . key? ( "ssl_verify_mode" ) )
241
- raise LogStash ::ConfigurationError , "Both ' ssl_verify_mode' and ' verify_mode' were set. Use only ' ssl_verify_mode' ."
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` ."
242
250
elsif original_params . key? ( "verify_mode" )
243
251
@ssl_verify_mode_final = @verify_mode
244
- elsif original_params . key? ( "ssl_verify_mode" )
245
- @ssl_verify_mode_final = @ssl_verify_mode
246
252
else
247
253
@ssl_verify_mode_final = @ssl_verify_mode
248
254
end
249
255
250
- if @ssl && require_certificate_authorities? && !client_authentication?
251
- raise LogStash ::ConfigurationError , "Using `ssl_verify_mode` or `verify_mode` set to PEER or FORCE_PEER, requires the configuration of `ssl_certificate_authorities`"
252
- elsif @ssl && !require_certificate_authorities? && client_authentication?
253
- raise LogStash ::ConfigurationError , "The configuration of `ssl_certificate_authorities` requires setting `ssl_verify_mode` or `verify_mode` to PEER or FORCE_PEER"
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
262
+ end
263
+
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
273
+ end
274
+ end
275
+
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"
254
280
end
255
281
end
256
282
@@ -268,7 +294,7 @@ def build_ssl_params
268
294
begin
269
295
ssl_builder = org . logstash . plugins . inputs . http . util . SslSimpleBuilder
270
296
. new ( @ssl_certificate , @ssl_key , @ssl_key_passphrase . nil? ? nil : @ssl_key_passphrase . value )
271
- . setCipherSuites ( normalized_ciphers )
297
+ . setCipherSuites ( normalized_cipher_suites )
272
298
rescue java . lang . IllegalArgumentException => e
273
299
@logger . error ( "SSL configuration invalid" , error_details ( e ) )
274
300
raise LogStash ::ConfigurationError , e
@@ -300,19 +326,15 @@ def require_certificate_authorities?
300
326
301
327
private
302
328
303
- def normalized_ciphers
304
- @cipher_suites . map ( &:upcase )
305
- end
306
-
307
- def convert_protocols
308
- TLS . get_supported ( @tls_min_version ..@tls_max_version ) . map ( &:name )
329
+ def normalized_cipher_suites
330
+ @ssl_cipher_suites_final . map ( &:upcase )
309
331
end
310
332
311
333
def new_ssl_handshake_provider ( ssl_builder )
312
334
begin
313
335
ssl_handler_provider = org . logstash . plugins . inputs . http . util . SslHandlerProvider . new ( ssl_builder . build ( ) )
314
336
ssl_handler_provider . setVerifyMode ( @ssl_verify_mode_final . upcase )
315
- ssl_handler_provider . setProtocols ( convert_protocols )
337
+ ssl_handler_provider . setProtocols ( @ssl_supported_protocols_final )
316
338
ssl_handler_provider . setHandshakeTimeoutMilliseconds ( @ssl_handshake_timeout )
317
339
ssl_handler_provider
318
340
rescue java . lang . IllegalArgumentException => e
0 commit comments