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

ssl: add SSLContext#min_version= and #max_version= #142

Merged
merged 5 commits into from
Sep 3, 2017

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Aug 29, 2017

Add methods that set the minimum and maximum supported protocol
versions for the SSL context. If the OpenSSL library supports, use
SSL_CTX_set_{min,max}proto_version() that do the exact thing.
Otherwise, simulate by combining SSL_OP_NO
{SSL,TLS}v* flags.

The new methods are meant to replace the deprecated
SSLContext#ssl_version= that cannot support multiple protocol versions.

SSLContext::DEFAULT_PARAMS is also updated to use the new
SSLContext#min_version=.

@rhenium rhenium force-pushed the ky/ssl-version-min-max branch 2 times, most recently from 5a60eda to ae15316 Compare August 31, 2017 15:54
SSL_CTX_{get,set,clear}_options() are made separate functions and they
now treat flags as unsigned long. Fix possible RangeError on platforms
with sizeof(long)==4.
Reorder, expand ossl_ssl_def_const() macro so RDoc can parse and render
better, and add new flags that are in recent versions of OpenSSL.
OpenSSL 1.1.0 replaced SSLv23_method() with TLS_method(). SSLv23_method
which still exists in 1.1.0, as a macro around TLS_method, will
eventually be removed. Use the new name if possible.
@rhenium rhenium force-pushed the ky/ssl-version-min-max branch 4 times, most recently from fb11c04 to da704fc Compare September 3, 2017 01:45
Add methods that set the minimum and maximum supported protocol versions
for the SSL context. If the OpenSSL library supports, use
SSL_CTX_set_{min,max}_proto_version() that do the exact thing.
Otherwise, simulate by combining SSL_OP_NO_{SSL,TLS}v* flags.

The new methods are meant to replace the deprecated #ssl_version= that
cannot support multiple protocol versions.

SSLContext::DEFAULT_PARAMS is also updated to use the new
SSLContext#min_version=.
Reimplement SSLContext#ssl_version= as a wrapper around
SSLContext#min_version= and #max_version=.

SSLContext#ssl_version= used to call SSL_CTX_set_ssl_version() which
replaces the SSL method used for the connections created from the SSL
context. This is mainly used for forcing a specific SSL/TLS protocol
version.

As of OpenSSL 1.1.0, however, use of the version-specific SSL methods
such as TLSv1_method() is deprecated. Follow the current recommendation
-- to use the generic SSL method always and to control the supported
version range by SSL_CTX_set_{min,max}_proto_version(). Actually, we
have already started doing a similar thing when the extension is
compiled with OpenSSL 1.1.0.

OpenSSL::SSL::SSLContext::METHODS, which contained the possible names of
SSL methods, is not useful anymore. It is now deprecate_constant-ed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant