@@ -93,8 +93,17 @@ def attr_config(symbol)
9393 # String name of OpenSSL's SSL version method name: TLSv1_2, TLSv1_1, TLSv1,
9494 # SSLv2, SSLv23, SSLv3 or :auto (and nil) to allow version negotiation (default).
9595 # See {OpenSSL::SSL::SSLContext::METHODS} for a list of available versions
96- # in your specific Ruby environment.
96+ # in your specific Ruby environment. This is
97+ # deprecated and only provided for backwards compatibility. Use
98+ # #min_version= and #max_version= instead.
9799 attr_config :ssl_version
100+ # Sets the upper bound on the supported SSL/TLS protocol version.
101+ # See min_version for possible values.
102+ attr_config :max_version
103+ # Sets the lower bound on the supported SSL/TLS protocol version.
104+ # The version may be specified by an integer constant named
105+ # OpenSSL::SSL::*_VERSION, a Symbol, or +nil+ which means "any version".
106+ attr_config :min_version
98107 # OpenSSL::X509::Certificate:: certificate for SSL client authentication.
99108 # nil by default. (no client authentication)
100109 attr_config :client_cert
@@ -123,7 +132,7 @@ def attr_config(symbol)
123132 # A number of OpenSSL's SSL options. Default value is
124133 # OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv2
125134 # CAUTION: this is OpenSSL specific option and ignored on JRuby.
126- # Use ssl_version to specify the TLS version you want to use.
135+ # Use min_version and max_version to specify the TLS versions you want to use.
127136 attr_config :options
128137 # A String of OpenSSL's cipher configuration. Default value is
129138 # ALL:!ADH:!LOW:!EXP:!MD5:+SSLv2:@STRENGTH
@@ -154,6 +163,8 @@ def initialize(client)
154163 @dest = nil
155164 @timeout = nil
156165 @ssl_version = :auto
166+ @max_version = nil
167+ @min_version = nil
157168 # Follow ruby-ossl's definition
158169 @options = OpenSSL ::SSL ::OP_ALL
159170 @options &= ~OpenSSL ::SSL ::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined? ( OpenSSL ::SSL ::OP_DONT_INSERT_EMPTY_FRAGMENTS )
@@ -303,6 +314,8 @@ def set_context(ctx) # :nodoc:
303314 ctx . options = @options
304315 ctx . ciphers = @ciphers
305316 ctx . ssl_version = @ssl_version unless @ssl_version == :auto
317+ ctx . min_version = @min_version if @min_version
318+ ctx . max_version = @max_version if @max_version
306319 end
307320
308321 # post connection check proc for ruby < 1.8.5.
0 commit comments