Skip to content
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

Fixes #12572 - refactor openssl settings #351

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/launcher.rb
Expand Up @@ -40,6 +40,11 @@ def https_app
::Proxy::Plugins.enabled_plugins.each {|p| instance_eval(p.https_rackup)}
end

ssl_options = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add OpenSSL::SSL::OP_NO_COMPRESSION option too? Looks like tls compression is on by default...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you seeing compression on by default? It was patched to be disabled as part of #9424 in 1.9.3 and newer. It also appears that RH has patched el6 to disable it as well.

ssl_options |= OpenSSL::SSL::OP_CIPHER_SERVER_PREFERENCE if defined?(OpenSSL::SSL::OP_CIPHER_SERVER_PREFERENCE)
ssl_options |= OpenSSL::SSL::OP_NO_TLSv1 if defined?(OpenSSL::SSL::OP_NO_TLSv1)
ssl_options |= OpenSSL::SSL::OP_NO_TLSv1_1 if defined?(OpenSSL::SSL::OP_NO_TLSv1_1)

Rack::Server.new(
:app => app,
:server => :webrick,
Expand All @@ -51,6 +56,7 @@ def https_app
:SSLPrivateKey => load_ssl_private_key(SETTINGS.ssl_private_key),
:SSLCertificate => load_ssl_certificate(SETTINGS.ssl_certificate),
:SSLCACertificateFile => SETTINGS.ssl_ca_file,
:SSLOptions => ssl_options,
:daemonize => false)
end
end
Expand Down
91 changes: 0 additions & 91 deletions lib/poodles-fix.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/smart_proxy_main.rb
Expand Up @@ -36,7 +36,7 @@
require 'sinatra'
require 'sinatra-patch'
require 'sinatra/authorization'
require 'poodles-fix'
require 'webrick-patch'

module Proxy
SETTINGS = Settings.load_global_settings
Expand Down
34 changes: 34 additions & 0 deletions lib/webrick-patch.rb
@@ -0,0 +1,34 @@
require 'webrick/https'

CIPHERS = 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-CBC-SHA:ECDHE-RSA-AES256-CBC-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA'

module WEBrick
class GenericServer
def setup_ssl_context(config) # :nodoc:
unless config[:SSLCertificate]
cn = config[:SSLCertName]
comment = config[:SSLCertComment]
cert, key = Utils::create_self_signed_cert(1024, cn, comment)
config[:SSLCertificate] = cert
config[:SSLPrivateKey] = key
end
ctx = OpenSSL::SSL::SSLContext.new
ctx.set_params
ctx.ciphers = CIPHERS
ctx.key = config[:SSLPrivateKey]
ctx.cert = config[:SSLCertificate]
ctx.client_ca = config[:SSLClientCA]
ctx.extra_chain_cert = config[:SSLExtraChainCert]
ctx.ca_file = config[:SSLCACertificateFile]
ctx.ca_path = config[:SSLCACertificatePath]
ctx.cert_store = config[:SSLCertificateStore]
ctx.tmp_dh_callback = config[:SSLTmpDhCallback]
ctx.verify_mode = config[:SSLVerifyClient]
ctx.verify_depth = config[:SSLVerifyDepth]
ctx.verify_callback = config[:SSLVerifyCallback]
ctx.timeout = config[:SSLTimeout]
ctx.options |= config[:SSLOptions] unless config[:SSLOptions].nil?
ctx
end
end
end