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

Conditionally add aliases for TLS 1.3 constants #653

Merged
merged 2 commits into from
Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/bunny/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@ class Transport
TLSv1: OpenSSL::SSL::TLS1_VERSION,
TLSv1_1: OpenSSL::SSL::TLS1_1_VERSION,
TLSv1_2: OpenSSL::SSL::TLS1_2_VERSION,
TLSv1_3: OpenSSL::SSL::TLS1_3_VERSION,
"1.0": OpenSSL::SSL::TLS1_VERSION,
"1.1": OpenSSL::SSL::TLS1_1_VERSION,
"1.2": OpenSSL::SSL::TLS1_2_VERSION,
"1.3": OpenSSL::SSL::TLS1_3_VERSION,
OpenSSL::SSL::TLS1_VERSION => OpenSSL::SSL::TLS1_VERSION,
OpenSSL::SSL::TLS1_1_VERSION => OpenSSL::SSL::TLS1_1_VERSION,
OpenSSL::SSL::TLS1_2_VERSION => OpenSSL::SSL::TLS1_2_VERSION,
OpenSSL::SSL::TLS1_3_VERSION => OpenSSL::SSL::TLS1_3_VERSION
}.freeze
OpenSSL::SSL::TLS1_2_VERSION => OpenSSL::SSL::TLS1_2_VERSION
}

# older OpenSSL versions won't support for TLS 1.3 and won't
# have this constant defined.
if defined?(OpenSSL::SSL::TLS1_3_VERSION)
TLS_VERSION_ALIASES["1.3"] = OpenSSL::SSL::TLS1_3_VERSION
TLS_VERSION_ALIASES[:TLSv1_3] = OpenSSL::SSL::TLS1_3_VERSION
TLS_VERSION_ALIASES[OpenSSL::SSL::TLS1_3_VERSION] = OpenSSL::SSL::TLS1_3_VERSION
end

TLS_VERSION_ALIASES.freeze

attr_reader :session, :host, :port, :socket, :connect_timeout, :read_timeout, :write_timeout, :disconnect_timeout
attr_reader :tls_context, :verify_peer, :tls_ca_certificates, :tls_certificate_path, :tls_key_path
Expand Down