Skip to content

Commit

Permalink
TF-8697: Support Ruby versions lacking OpenSSL constant (#300)
Browse files Browse the repository at this point in the history
* Support ruby 2.3

This restores support for much older versions of ruby such as 2.3. While
these versions are EOL'd, they do still appear in usage in things like
embedded chef. It's not a big change to restore functionality, so we've
done that.

* Update changelog and version number

---------

Co-authored-by: Evan Phoenix <evan@phx.io>
  • Loading branch information
sudomateo and evanphx authored Sep 14, 2023
1 parent 643d269 commit 7bb4a6f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
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

0 comments on commit 7bb4a6f

Please sign in to comment.