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

TF-8697: Support Ruby versions lacking OpenSSL constant #300

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## v?.??.? (Unreleased)

## v0.18.1 (September 14, 2023)

BUG FIXES

- Restored the ability to use this gem with older Ruby versions that do not have
the `OpenSSL::SSL::TLS1_2_VERSION` constant.

## v0.18.0 (September 14, 2023)

IMPROVEMENTS
Expand Down
10 changes: 8 additions & 2 deletions lib/vault/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class Client
a << PersistentHTTP::Error
end.freeze

# Vault requires at least TLS1.2
MIN_TLS_VERSION = if defined? OpenSSL::SSL::TLS1_2_VERSION
OpenSSL::SSL::TLS1_2_VERSION
else
"TLSv1_2"
end

include Vault::Configurable

# Create a new Client with the given options. Any options given take
Expand Down Expand Up @@ -112,8 +119,7 @@ def pool

@nhp.verify_mode = OpenSSL::SSL::VERIFY_PEER

# Vault requires at least TLS1.2
@nhp.min_version = OpenSSL::SSL::TLS1_2_VERSION
@nhp.min_version = MIN_TLS_VERSION

# Only use secure ciphers
@nhp.ciphers = ssl_ciphers
Expand Down
10 changes: 9 additions & 1 deletion lib/vault/persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,15 @@ def ssl connection
connection.use_ssl = true

connection.ciphers = @ciphers if @ciphers
connection.min_version = @min_version if @min_version

if @min_version
if connection.respond_to? :min_version=
connection.min_version = @min_version
else
connection.ssl_version = @min_version
end
end

connection.ssl_timeout = @ssl_timeout if @ssl_timeout

connection.verify_depth = @verify_depth
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# SPDX-License-Identifier: MPL-2.0

module Vault
VERSION = "0.18.0"
VERSION = "0.18.1"
end