Skip to content

Commit

Permalink
[refactor] cleanup load.rb (we can assume JRuby >= 9.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Sep 9, 2024
1 parent d67cf9a commit b6e9b2e
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions lib/jopenssl/load.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
warn 'Loading jruby-openssl gem in a non-JRuby interpreter' unless defined? JRUBY_VERSION

require 'jopenssl/version'

# NOTE: assuming user does pull in BC .jars from somewhere else on the CP
Expand All @@ -25,16 +23,7 @@
end

require 'jopenssl.jar'

if JRuby::Util.respond_to?(:load_ext) # JRuby 9.2
JRuby::Util.load_ext('org.jruby.ext.openssl.OpenSSL')
else; require 'jruby'
org.jruby.ext.openssl.OpenSSL.load(JRuby.runtime)
end

if RUBY_VERSION > '2.3'
load 'jopenssl/_compat23.rb'
end
JRuby::Util.load_ext('org.jruby.ext.openssl.OpenSSL')

# NOTE: content bellow should live in *lib/openssl.rb* but due RubyGems/Bundler
# `autoload :OpenSSL` this will cause issues if an older version (0.11) is the
Expand All @@ -61,7 +50,6 @@ module OpenSSL
require 'openssl/bn'
require 'openssl/pkey'
require 'openssl/cipher'
#require 'openssl/config' if OpenSSL.const_defined?(:Config, false)
require 'openssl/digest'
require 'openssl/hmac'
require 'openssl/x509'
Expand All @@ -80,4 +68,6 @@ def self.secure_compare(a, b)
hashed_b = OpenSSL::Digest.digest('SHA256', b)
OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
end
end
end

load 'jopenssl/_compat23.rb'

0 comments on commit b6e9b2e

Please sign in to comment.