-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: review and deprecate ssl protocol/cipher settings #151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, with deprecated config settings and the plugin starts cleanly with only the warnings, it doesn't create any breakage.
I've requested changes to know your opinion on those, if you feel it's worthwhile to simplify.
lib/logstash/inputs/http.rb
Outdated
if @ssl && (original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites')) | ||
raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`." | ||
elsif original_params.key?('cipher_suites') | ||
@ssl_cipher_suites_final = @cipher_suites | ||
else | ||
@ssl_cipher_suites_final = @ssl_cipher_suites | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if @ssl
is false
then @ssl_cipher_suites_final
end in:
- empty list if the user configured
cipher_suites
. SslSimpleBuilder.getDefaultCiphers
if the user in any other case.
I think that ifssl => false
it shouldn't set anything related to the ciphers
I know that the method build_ssl_params
has a guard:
return nil unless @ssl
Maybe isolating the fragment with an if @ssl
should help.
if @ssl && (original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites')) | |
raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`." | |
elsif original_params.key?('cipher_suites') | |
@ssl_cipher_suites_final = @cipher_suites | |
else | |
@ssl_cipher_suites_final = @ssl_cipher_suites | |
end | |
if @ssl | |
if original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites') | |
raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`." | |
@ssl_cipher_suites_final = original_params.key?('cipher_suites') ? | |
@cipher_suites : | |
@ssl_cipher_suites | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssl_cipher_suites_final
won't be used since build_ssl_params
isn't called.
the reason why I have it this way is due existing convention above:
# ...
elsif original_params.key?("verify_mode")
@ssl_verify_mode_final = @verify_mode
else
@ssl_verify_mode_final = @ssl_verify_mode
lib/logstash/inputs/http.rb
Outdated
if @ssl && (original_params.key?('tls_min_version') && original_params.key?('ssl_supported_protocols')) | ||
raise LogStash::ConfigurationError, "Both `ssl_supported_protocols` and (deprecated) `tls_min_ciphers` were set. Use only `ssl_supported_protocols`." | ||
elsif @ssl && (original_params.key?('tls_max_version') && original_params.key?('ssl_supported_protocols')) | ||
raise LogStash::ConfigurationError, "Both `ssl_supported_protocols` and (deprecated) `tls_max_ciphers` were set. Use only `ssl_supported_protocols`." | ||
else | ||
if @ssl && (original_params.key?('tls_min_version') || original_params.key?('tls_max_version')) | ||
@ssl_supported_protocols_final = TLS.get_supported(tls_min_version..tls_max_version).map(&:name) | ||
else | ||
@ssl_supported_protocols_final = @ssl_supported_protocols | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same observation as the one above, protect with an if @ssl
could make it more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the attr is not set @ssl_supported_protocols_final = @ssl_supported_protocols
is just nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a compromise refactoring: db159bb ... wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compromise is almost good, I would made it more "assertive", I mean that if an if
statement return
in the positive branch then simplify the negative branch.
so
if !@ssl
@logger.warn("SSL Certificate will not be used") if @ssl_certificate
@logger.warn("SSL Key will not be used") if @ssl_key
@logger.warn("SSL Java Key Store will not be used") if @keystore
return # code bellow assumes `ssl => true`
elsif !(ssl_key_configured? || ssl_jks_configured?)
raise LogStash::ConfigurationError, "Certificate or JKS must be configured"
end
becomes:
if !@ssl
@logger.warn("SSL Certificate will not be used") if @ssl_certificate
@logger.warn("SSL Key will not be used") if @ssl_key
@logger.warn("SSL Java Key Store will not be used") if @keystore
return
end
# code below assumes `ssl => true`
if !(ssl_key_configured? || ssl_jks_configured?)
raise LogStash::ConfigurationError, "Certificate or JKS must be configured"
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left just maybe a nitpick at #151 (comment) but I think it makes the code more readable.
Everything else seems ok to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
following up on #146:
cipher_suites
in favor ofssl_cipher_suites
(with better validation of the supported cipher set)ssl_supported_protocols
as a replacement fortls_min_version
/tls_max_version