Skip to content

Commit

Permalink
Merge pull request #379 from oneclick/openssl-provider
Browse files Browse the repository at this point in the history
Move bundled OpenSSL related files to bin/lib subdirectory.
  • Loading branch information
larskanis committed Apr 25, 2024
2 parents d3fc73a + a1a02f0 commit 88d8c1f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Update to ruby-3.2.4, see [release notes](https://www.ruby-lang.org/en/news/2024/04/23/ruby-3-2-4-released/).
- Update the SSL CA certificate list.
- Update to OpenSSL-3.3.0. The Ruby API dosn't change.
- Move bundled OpenSSL related files to bin/lib subdirectory so that legacy algorithms can be loaded through provider support. #365
- Update the bundled MSYS2 keyring package.
- Avoid crash even if a registry key incldues inconvertible characters
- Avoid method redefinition warning in rubygems hook
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG-3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Update to ruby-3.3.1, see [release notes](https://www.ruby-lang.org/en/news/2024/04/23/ruby-3-3-1-released/).
- Update the SSL CA certificate list.
- Update to OpenSSL-3.3.0. The Ruby API dosn't change.
- Move bundled OpenSSL related files to bin/lib subdirectory so that legacy algorithms can be loaded through provider support. #365
- Update the bundled MSYS2 keyring package.
- Avoid crash even if a registry key incldues inconvertible characters
- Avoid method redefinition warning in rubygems hook
Expand Down
22 changes: 22 additions & 0 deletions recipes/sandbox/70-move-openssl-files-to-bin.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Move bundled OpenSSL related files to bin/lib subdirectory.
# This is necessary because libcrypt.dll and libssl.dll are located in bin/ruby_builtin_dlls and they search other dlls in ../lib

if package.rubyver2 >= "3.2"
osl_files = %w[
lib/engines-3/capi.dll
lib/engines-3/loader_attic.dll
lib/engines-3/padlock.dll
lib/ossl-modules/legacy.dll
]

osl_files.each do |path|
# Add tasks to write the DLLs into the sub directory
destpath = File.join(sandboxdir, "bin", path)
file destpath => [File.join(unpackdirmgw, path), File.dirname(destpath)] do |t|
cp(t.prerequisites.first, t.name)
end

# Add the DLLs in the dependent files list to the subdirectory
self.sandboxfiles << destpath
end
end
4 changes: 0 additions & 4 deletions recipes/sandbox/rubyinstaller-3.2.4.files
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ bin/ruby.exe
bin/rubyw.exe
bin/zlib1.dll
include/ruby-3.2.0
lib/engines-3/capi.dll
lib/engines-3/loader_attic.dll
lib/engines-3/padlock.dll
lib/ossl-modules/legacy.dll
lib/pkgconfig/ruby-3.2.pc
lib/ruby/3.2.0
lib/ruby/gems/3.2.0
Expand Down
4 changes: 0 additions & 4 deletions recipes/sandbox/rubyinstaller-3.3.1.files
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ bin/ruby.exe
bin/rubyw.exe
bin/zlib1.dll
include/ruby-3.3.0
lib/engines-3/capi.dll
lib/engines-3/loader_attic.dll
lib/engines-3/padlock.dll
lib/ossl-modules/legacy.dll
lib/pkgconfig/ruby-3.3.pc
lib/ruby/3.3.0
lib/ruby/gems/3.3.0
Expand Down
4 changes: 0 additions & 4 deletions recipes/sandbox/rubyinstaller-head.files
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ bin/ruby.exe
bin/rubyw.exe
bin/zlib1.dll
include/ruby-3.4.0+0
lib/engines-3/capi.dll
lib/engines-3/loader_attic.dll
lib/engines-3/padlock.dll
lib/ossl-modules/legacy.dll
lib/pkgconfig/ruby-3.4.pc
lib/ruby/3.4.0+0
lib/ruby/gems/3.4.0+0
Expand Down
10 changes: 10 additions & 0 deletions test/test_stdlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,14 @@ def test_openssl_version
assert_match(/OpenSSL 3\./, OpenSSL::OPENSSL_LIBRARY_VERSION)
end
end

def test_openssl_provider
# ruby-3.2 has OpenSSL-3.x which supports provider API, but the ruby C-ext is too old there
return if RUBY_VERSION =~ /^2\.[34567]\.|^3\.[012]\./
require "openssl"

OpenSSL::Provider.load("legacy")
cipher = OpenSSL::Cipher.new("RC4")
assert_equal "RC4", cipher.name
end
end

0 comments on commit 88d8c1f

Please sign in to comment.