- 
                Notifications
    You must be signed in to change notification settings 
- Fork 182
ssl: do not enable OpenSSL::SSL::OP_ALL by default #767
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
          
     Merged
      
      
            rhenium
  merged 3 commits into
  ruby:master
from
rhenium:ky/ssl-respect-default-ssl-options
  
      
      
   
  Dec 7, 2024 
      
    
                
     Merged
            
            ssl: do not enable OpenSSL::SSL::OP_ALL by default #767
                    rhenium
  merged 3 commits into
  ruby:master
from
rhenium:ky/ssl-respect-default-ssl-options
  
      
      
   
  Dec 7, 2024 
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Respect the SSL options set by default by SSL_CTX() and by the system-wide OpenSSL configuration file. OpenSSL::SSL::SSLContext#initialize currently adds OpenSSL::SSL::OP_ALL on top of the default SSL options. Let's stop doing it. OpenSSL::SSL::OP_ALL is a set of options that changes OpenSSL's behavior to workaround various TLS implementation bugs. Using it is considered usually safe, but is not completely harmless.
Apply SSL options set in DEFAULT_PARAMS without clearing existing options. It currently clears options in order to avoid setting one of the options included in OpenSSL::SSL::OP_ALL unless explicitly specified, namely OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS. Now that OpenSSL::SSL::OP_ALL has been removed from SSLContext#initialize, it is no longer necessary.
fc6d2c1    to
    77c3db2      
    Compare
  
    
    
  rhenium 
      added a commit
        to rhenium/ruby-openssl
      that referenced
      this pull request
    
      Jan 30, 2025 
    
    
      
  
    
      
    
  
Make these methods simple wrappers around
SSL_CTX_set_{min,max}_proto_version().
When we introduced these methods in commit 1860394 [1], which went
to v2.1.0, we added a private method to SSLContext that set both the
minimum and maximum protocol versions at the same time. This was to
allow emulating the behavior using SSL options on older OpenSSL versions
that lack SSL_CTX_set_{min,max}_proto_version(). Since we no longer
support OpenSSL 1.0.2, the related code has already been removed.
In OpenSSL 1.1.1 or later, setting the minimum or maximum version to 0
is not equivalent to leaving it unset. Similar to SSL options, which we
avoid overwriting as of commit 00bec0d and commit 77c3db2 [2],
a system-wide configuration file may define a default protocol version
bounds. Setting the minimum version should not unset the maximum
version, and vice versa.
[1] ruby#142
[2] ruby#767
    
    
  rhenium 
      added a commit
        to rhenium/ruby-openssl
      that referenced
      this pull request
    
      Jan 31, 2025 
    
    
      
  
    
      
    
  
Make these methods simple wrappers around
SSL_CTX_set_{min,max}_proto_version().
When we introduced these methods in commit 1860394 [1], which went
to v2.1.0, we added a private method to SSLContext that set both the
minimum and maximum protocol versions at the same time. This was to
allow emulating the behavior using SSL options on older OpenSSL versions
that lack SSL_CTX_set_{min,max}_proto_version(). Since we no longer
support OpenSSL 1.0.2, the related code has already been removed.
In OpenSSL 1.1.1 or later, setting the minimum or maximum version to 0
is not equivalent to leaving it unset. Similar to SSL options, which we
avoid overwriting as of commit 00bec0d and commit 77c3db2 [2],
a system-wide configuration file may define a default protocol version
bounds. Setting the minimum version should not unset the maximum
version, and vice versa.
[1] ruby#142
[2] ruby#767
    
    
  matzbot 
      pushed a commit
        to ruby/ruby
      that referenced
      this pull request
    
      Feb 3, 2025 
    
    
      
  
    
      
    
  
Make these methods simple wrappers around
SSL_CTX_set_{min,max}_proto_version().
When we introduced these methods in commit ruby/openssl@18603949d316 [1], which went
to v2.1.0, we added a private method to SSLContext that set both the
minimum and maximum protocol versions at the same time. This was to
allow emulating the behavior using SSL options on older OpenSSL versions
that lack SSL_CTX_set_{min,max}_proto_version(). Since we no longer
support OpenSSL 1.0.2, the related code has already been removed.
In OpenSSL 1.1.1 or later, setting the minimum or maximum version to 0
is not equivalent to leaving it unset. Similar to SSL options, which we
avoid overwriting as of commit ruby/openssl@00bec0d905d5 and commit ruby/openssl@77c3db2d6587 [2],
a system-wide configuration file may define a default protocol version
bounds. Setting the minimum version should not unset the maximum
version, and vice versa.
[1] ruby/openssl#142
[2] ruby/openssl#767
ruby/openssl@5766386321
    
    
  eth-rangermaz32 
      added a commit
        to eth-rangermaz32/openssl
      that referenced
      this pull request
    
      Sep 27, 2025 
    
    
      
  
    
      
    
  
Make these methods simple wrappers around
SSL_CTX_set_{min,max}_proto_version().
When we introduced these methods in commit 18603949d316 [1], which went
to v2.1.0, we added a private method to SSLContext that set both the
minimum and maximum protocol versions at the same time. This was to
allow emulating the behavior using SSL options on older OpenSSL versions
that lack SSL_CTX_set_{min,max}_proto_version(). Since we no longer
support OpenSSL 1.0.2, the related code has already been removed.
In OpenSSL 1.1.1 or later, setting the minimum or maximum version to 0
is not equivalent to leaving it unset. Similar to SSL options, which we
avoid overwriting as of commit 00bec0d905d5 and commit 77c3db2d6587 [2],
a system-wide configuration file may define a default protocol version
bounds. Setting the minimum version should not unset the maximum
version, and vice versa.
[1] ruby/openssl#142
[2] ruby/openssl#767
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Respect the SSL options set by default by
SSL_CTX()or by the system-wide OpenSSL configuration file.OpenSSL::SSL::SSLContext#initializecurrently addsOpenSSL::SSL::OP_ALLon top of the default SSL options. Let's stop doing it.OpenSSL::SSL::OP_ALLis a set of options that changes OpenSSL's behavior to workaround various TLS implementation bugs. Using it is considered usually safe, but is not completely harmless.Also:
ssl: do not clear existing SSL options in
SSLContext#set_paramsApply SSL options set in
DEFAULT_PARAMSwithout clearing existing options, which may be set by a system-wide configuration file.With a fresh installation of OpenSSL 3.3.1, this change will enable the
OpenSSL::SSL::OP_ENABLE_MIDDLEBOX_COMPAToption for users ofSSLContext#set_params.The last commit in this PR fixes #765.