@@ -30,6 +30,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
3030 require "logstash/inputs/http/tls"
3131
3232 java_import "io.netty.handler.codec.http.HttpUtil"
33+ java_import 'org.logstash.plugins.inputs.http.util.SslSimpleBuilder'
3334
3435 config_name "http"
3536
@@ -86,16 +87,11 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
8687 # Time in milliseconds for an incomplete ssl handshake to timeout
8788 config :ssl_handshake_timeout , :validate => :number , :default => 10000
8889
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-
9790 # 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
9995
10096 # Apply specific codecs for specific content types.
10197 # The default codec will be applied only after this list is checked
@@ -118,14 +114,23 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
118114 config :max_content_length , :validate => :number , :required => false , :default => 100 * 1024 * 1024
119115
120116 config :response_code , :validate => [ 200 , 201 , 202 , 204 ] , :default => 200
117+
121118 # Deprecated options
122119
123120 # The JKS keystore to validate the client's certificates
124121 config :keystore , :validate => :path , :deprecated => "Set 'ssl_certificate' and 'ssl_key' instead."
125122 config :keystore_password , :validate => :password , :deprecated => "Set 'ssl_key_passphrase' instead."
126123
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."
129134
130135 attr_reader :codecs
131136
@@ -233,24 +238,45 @@ def validate_ssl_settings!
233238 @logger . warn ( "SSL Certificate will not be used" ) if @ssl_certificate
234239 @logger . warn ( "SSL Key will not be used" ) if @ssl_key
235240 @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? )
237245 raise LogStash ::ConfigurationError , "Certificate or JKS must be configured"
238246 end
239247
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` ."
242250 elsif original_params . key? ( "verify_mode" )
243251 @ssl_verify_mode_final = @verify_mode
244- elsif original_params . key? ( "ssl_verify_mode" )
245- @ssl_verify_mode_final = @ssl_verify_mode
246252 else
247253 @ssl_verify_mode_final = @ssl_verify_mode
248254 end
249255
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"
254280 end
255281 end
256282
@@ -268,7 +294,7 @@ def build_ssl_params
268294 begin
269295 ssl_builder = org . logstash . plugins . inputs . http . util . SslSimpleBuilder
270296 . new ( @ssl_certificate , @ssl_key , @ssl_key_passphrase . nil? ? nil : @ssl_key_passphrase . value )
271- . setCipherSuites ( normalized_ciphers )
297+ . setCipherSuites ( normalized_cipher_suites )
272298 rescue java . lang . IllegalArgumentException => e
273299 @logger . error ( "SSL configuration invalid" , error_details ( e ) )
274300 raise LogStash ::ConfigurationError , e
@@ -300,19 +326,15 @@ def require_certificate_authorities?
300326
301327 private
302328
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 )
309331 end
310332
311333 def new_ssl_handshake_provider ( ssl_builder )
312334 begin
313335 ssl_handler_provider = org . logstash . plugins . inputs . http . util . SslHandlerProvider . new ( ssl_builder . build ( ) )
314336 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 )
316338 ssl_handler_provider . setHandshakeTimeoutMilliseconds ( @ssl_handshake_timeout )
317339 ssl_handler_provider
318340 rescue java . lang . IllegalArgumentException => e
0 commit comments