Skip to content

Commit cf9cf98

Browse files
authored
Merge pull request #8624 from joshcooper/drop_ruby_monkey_patches
(maint) Drop ruby monkey patches
2 parents 26b735e + 0e68cf7 commit cf9cf98

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

lib/puppet/util/monkey_patches.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ def daemonize
3232
# (#19151) Reject all SSLv2 ciphers and handshakes
3333
require_relative '../../puppet/ssl/openssl_loader'
3434
unless Puppet::Util::Platform.jruby_fips?
35-
unless defined?(OpenSSL::SSL::TLS1_VERSION)
36-
module OpenSSL::SSL
37-
# see https://github.com/ruby/ruby/commit/609103dbb5fb182eec12f052226c43e39b907682#diff-09f822c26289f5347111795ca22ed7ed1cfadd6ebd28f987991d1d414eef565aR2755-R2759
38-
OpenSSL::SSL::TLS1_VERSION = 0x301
39-
end
40-
end
41-
4235
class OpenSSL::SSL::SSLContext
4336
if DEFAULT_PARAMS[:options]
4437
DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
@@ -94,20 +87,12 @@ def set_default_paths
9487
OpenSSL::X509.const_set(:V_ERR_HOSTNAME_MISMATCH, 62)
9588
end
9689

90+
# jruby-openssl doesn't support this
9791
unless OpenSSL::X509::Name.instance_methods.include?(:to_utf8)
9892
class OpenSSL::X509::Name
99-
# https://github.com/openssl/openssl/blob/OpenSSL_1_1_0j/include/openssl/asn1.h#L362
100-
ASN1_STRFLGS_ESC_MSB = 4
101-
102-
FLAGS = if RUBY_PLATFORM == 'java'
103-
OpenSSL::X509::Name::RFC2253
104-
else
105-
OpenSSL::X509::Name::RFC2253 & ~ASN1_STRFLGS_ESC_MSB
106-
end
107-
10893
def to_utf8
10994
# https://github.com/ruby/ruby/blob/v2_5_5/ext/openssl/ossl_x509name.c#L317
110-
str = to_s(FLAGS)
95+
str = to_s(OpenSSL::X509::Name::RFC2253)
11196
str.force_encoding(Encoding::UTF_8)
11297
end
11398
end

lib/puppet/x509/cert_provider.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,7 @@ def load_private_key(name, required: false, password: nil)
207207
# @api private
208208
def load_private_key_from_pem(pem, password: nil)
209209
# set a non-nil password to ensure openssl doesn't prompt
210-
# but ruby 2.4.0 & 2.4.1 require at least 4 bytes due to
211-
# https://github.com/ruby/openssl/commit/f38501249f33bff7ca9d208670b8cde695ea8b7b
212-
# and corrected in https://github.com/ruby/openssl/commit/a896c3d1dfa090e92dec1abf8ac12843af6af721
213-
password ||= ' '
210+
password ||= ''
214211

215212
# Can't use OpenSSL::PKey.read, because it's broken in MRI 2.3, doesn't exist
216213
# in JRuby 9.1, and is broken in JRuby 9.2

0 commit comments

Comments
 (0)