Skip to content

Commit a1a02f0

Browse files
committed
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 Fixes #365
1 parent d3fc73a commit a1a02f0

7 files changed

+34
-12
lines changed

CHANGELOG-3.2.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Update to ruby-3.2.4, see [release notes](https://www.ruby-lang.org/en/news/2024/04/23/ruby-3-2-4-released/).
55
- Update the SSL CA certificate list.
66
- Update to OpenSSL-3.3.0. The Ruby API dosn't change.
7+
- Move bundled OpenSSL related files to bin/lib subdirectory so that legacy algorithms can be loaded through provider support. #365
78
- Update the bundled MSYS2 keyring package.
89
- Avoid crash even if a registry key incldues inconvertible characters
910
- Avoid method redefinition warning in rubygems hook

CHANGELOG-3.3.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Update to ruby-3.3.1, see [release notes](https://www.ruby-lang.org/en/news/2024/04/23/ruby-3-3-1-released/).
55
- Update the SSL CA certificate list.
66
- Update to OpenSSL-3.3.0. The Ruby API dosn't change.
7+
- Move bundled OpenSSL related files to bin/lib subdirectory so that legacy algorithms can be loaded through provider support. #365
78
- Update the bundled MSYS2 keyring package.
89
- Avoid crash even if a registry key incldues inconvertible characters
910
- Avoid method redefinition warning in rubygems hook
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Move bundled OpenSSL related files to bin/lib subdirectory.
2+
# This is necessary because libcrypt.dll and libssl.dll are located in bin/ruby_builtin_dlls and they search other dlls in ../lib
3+
4+
if package.rubyver2 >= "3.2"
5+
osl_files = %w[
6+
lib/engines-3/capi.dll
7+
lib/engines-3/loader_attic.dll
8+
lib/engines-3/padlock.dll
9+
lib/ossl-modules/legacy.dll
10+
]
11+
12+
osl_files.each do |path|
13+
# Add tasks to write the DLLs into the sub directory
14+
destpath = File.join(sandboxdir, "bin", path)
15+
file destpath => [File.join(unpackdirmgw, path), File.dirname(destpath)] do |t|
16+
cp(t.prerequisites.first, t.name)
17+
end
18+
19+
# Add the DLLs in the dependent files list to the subdirectory
20+
self.sandboxfiles << destpath
21+
end
22+
end

recipes/sandbox/rubyinstaller-3.2.4.files

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ bin/ruby.exe
2828
bin/rubyw.exe
2929
bin/zlib1.dll
3030
include/ruby-3.2.0
31-
lib/engines-3/capi.dll
32-
lib/engines-3/loader_attic.dll
33-
lib/engines-3/padlock.dll
34-
lib/ossl-modules/legacy.dll
3531
lib/pkgconfig/ruby-3.2.pc
3632
lib/ruby/3.2.0
3733
lib/ruby/gems/3.2.0

recipes/sandbox/rubyinstaller-3.3.1.files

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ bin/ruby.exe
2828
bin/rubyw.exe
2929
bin/zlib1.dll
3030
include/ruby-3.3.0
31-
lib/engines-3/capi.dll
32-
lib/engines-3/loader_attic.dll
33-
lib/engines-3/padlock.dll
34-
lib/ossl-modules/legacy.dll
3531
lib/pkgconfig/ruby-3.3.pc
3632
lib/ruby/3.3.0
3733
lib/ruby/gems/3.3.0

recipes/sandbox/rubyinstaller-head.files

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ bin/ruby.exe
2828
bin/rubyw.exe
2929
bin/zlib1.dll
3030
include/ruby-3.4.0+0
31-
lib/engines-3/capi.dll
32-
lib/engines-3/loader_attic.dll
33-
lib/engines-3/padlock.dll
34-
lib/ossl-modules/legacy.dll
3531
lib/pkgconfig/ruby-3.4.pc
3632
lib/ruby/3.4.0+0
3733
lib/ruby/gems/3.4.0+0

test/test_stdlib.rb

+10
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,14 @@ def test_openssl_version
7777
assert_match(/OpenSSL 3\./, OpenSSL::OPENSSL_LIBRARY_VERSION)
7878
end
7979
end
80+
81+
def test_openssl_provider
82+
# ruby-3.2 has OpenSSL-3.x which supports provider API, but the ruby C-ext is too old there
83+
return if RUBY_VERSION =~ /^2\.[34567]\.|^3\.[012]\./
84+
require "openssl"
85+
86+
OpenSSL::Provider.load("legacy")
87+
cipher = OpenSSL::Cipher.new("RC4")
88+
assert_equal "RC4", cipher.name
89+
end
8090
end

0 commit comments

Comments
 (0)