@@ -95,8 +95,17 @@ def attr_config(symbol)
9595 # String name of OpenSSL's SSL version method name: TLSv1_2, TLSv1_1, TLSv1,
9696 # SSLv2, SSLv23, SSLv3 or :auto (and nil) to allow version negotiation (default).
9797 # See {OpenSSL::SSL::SSLContext::METHODS} for a list of available versions
98- # in your specific Ruby environment.
98+ # in your specific Ruby environment. This is
99+ # deprecated and only provided for backwards compatibility. Use
100+ # #min_version= and #max_version= instead.
99101 attr_config :ssl_version
102+ # Sets the upper bound on the supported SSL/TLS protocol version.
103+ # See min_version for possible values.
104+ attr_config :max_version
105+ # Sets the lower bound on the supported SSL/TLS protocol version.
106+ # The version may be specified by an integer constant named
107+ # OpenSSL::SSL::*_VERSION, a Symbol, or +nil+ which means "any version".
108+ attr_config :min_version
100109 # OpenSSL::X509::Certificate:: certificate for SSL client authentication.
101110 # nil by default. (no client authentication)
102111 attr_config :client_cert
@@ -125,7 +134,7 @@ def attr_config(symbol)
125134 # A number of OpenSSL's SSL options. Default value is
126135 # OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv2
127136 # CAUTION: this is OpenSSL specific option and ignored on JRuby.
128- # Use ssl_version to specify the TLS version you want to use.
137+ # Use min_version and max_version to specify the TLS versions you want to use.
129138 attr_config :options
130139 # A String of OpenSSL's cipher configuration. Default value is
131140 # ALL:!ADH:!LOW:!EXP:!MD5:+SSLv2:@STRENGTH
@@ -158,6 +167,8 @@ def initialize(client)
158167 @dest = nil
159168 @timeout = nil
160169 @ssl_version = :auto
170+ @max_version = nil
171+ @min_version = nil
161172 # Follow ruby-ossl's definition
162173 @options = OpenSSL ::SSL ::OP_ALL
163174 @options &= ~OpenSSL ::SSL ::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined? ( OpenSSL ::SSL ::OP_DONT_INSERT_EMPTY_FRAGMENTS )
@@ -309,6 +320,8 @@ def set_context(ctx) # :nodoc:
309320 ctx . options = @options
310321 ctx . ciphers = @ciphers
311322 ctx . ssl_version = @ssl_version unless @ssl_version == :auto
323+ ctx . min_version = @min_version if @min_version
324+ ctx . max_version = @max_version if @max_version
312325 end
313326
314327 # post connection check proc for ruby < 1.8.5.
0 commit comments