Skip to content
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

Windows 10 MSYS2 openssl-3.4.0 "LoadError - The specified procedure could not be found." #812

Open
andrewngo opened this issue Oct 29, 2024 · 9 comments

Comments

@andrewngo
Copy link

Not able to require 'openssl' on Windows after updating the MSYS2 openssl library. I'm able to install it and I see the openssl.so file but it still doesn't run.

Packages (18) bsdtar-3.7.7-1  curl-8.10.1-1  gawk-5.3.1-1  info-7.1.1-1  libcurl-8.10.1-1  libexpat-2.6.3-1
              libgnutls-3.8.7-1  liblzma-5.6.3-1  libnghttp2-1.64.0-1  libopenssl-3.4.0-1  libreadline-8.2.013-1
              libsqlite-3.46.1-1  msys2-keyring-1~20241007-1  msys2-launcher-1.5-2  nano-8.2-1  ncurses-6.5.20240831-2
              openssl-3.4.0-1  xz-5.6.3-1

Packages (1) mingw-w64-x86_64-openssl-3.4.0-1
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
>>
<internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': 127: The specified procedure could not be found.   - C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/openssl-3.2.0/lib/openssl.so (LoadError)
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/openssl-3.2.0/lib/openssl.rb:13:in `<top (required)>'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'

Computer info

 ruby -v
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]

gem list openssl

*** LOCAL GEMS ***

openssl (3.2.0, default: 3.1.0, 3.0.1)

[System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      20348  0
@MSP-Greg
Copy link
Contributor

Try using mingw-w64-ucrt-x86_64-openssl. You listed mingw-w64-x86_64-openssl, which is the wrong package for Ruby 3.2.3, which shows x64-mingw-ucrt...

@andrewngo
Copy link
Author

andrewngo commented Oct 29, 2024

Both seem to be installed. Is there a way to force the package?

I use these commands to install it

call %ruby_dir%\bin\ridk exec pacman -Sy
call %ruby_dir%\bin\ridk install 2 3

and then pacman shows the following:

C:\tools\msys64\usr\bin\pacman.exe -Q | findstr openssl

libopenssl 3.4.0-1
mingw-w64-ucrt-x86_64-openssl 3.4.0-1
mingw-w64-x86_64-openssl 3.4.0-1
openssl 3.4.0-1
C:\tools\msys64\usr\bin\pacman.exe -Ss | findstr openssl
clangarm64/mingw-w64-clang-aarch64-openssl 3.4.0-1
clangarm64/mingw-w64-clang-aarch64-python-pyopenssl 24.2.1-2
mingw32/mingw-w64-i686-openssl 3.4.0-1
mingw32/mingw-w64-i686-python-pyopenssl 24.2.1-2
mingw64/mingw-w64-x86_64-openssl 3.4.0-1 [installed]
mingw64/mingw-w64-x86_64-python-pyopenssl 24.2.1-2
ucrt64/mingw-w64-ucrt-x86_64-openssl 3.4.0-1 [installed]
ucrt64/mingw-w64-ucrt-x86_64-python-pyopenssl 24.2.1-2
clang32/mingw-w64-clang-i686-openssl 3.4.0-1
clang64/mingw-w64-clang-x86_64-openssl 3.4.0-1
clang64/mingw-w64-clang-x86_64-python-pyopenssl 24.2.1-2
msys/libopenssl 3.4.0-1 (libraries) [installed]
msys/openssl 3.4.0-1 [installed]
msys/openssl-devel 3.4.0-1 (development)
msys/openssl-docs 3.4.0-1

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Oct 29, 2024

I could repro the issue.

I haven't been in OpenSSL for a few months. It appears that OpenSSL 3.4 and 3.3 have some differences.

If I rename the OpenSSL dll's in Ruby's bin/ruby_builtin_dlls folder and copy the OpenSSL dlls from MSY2's ucrt64/bin into the Ruby folder, ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION works and shows OpenSSL 3.4.0 22 Oct 2024.

If you don't want to copy the dlls, you can get the OpenSSL 3.3.x packages from https://repo.msys2.org/mingw/ucrt64/. You'll have to uninstall Ruby OpenSSL 3.2.0 and reinstall it.

@andrewngo
Copy link
Author

Thanks. I copied libcrypto-3-x64.dll and libssl-3-x64.dll and that unblocks me for now. Appreciate it!

@rhenium
Copy link
Member

rhenium commented Oct 30, 2024

I noticed our CI builds with Ruby 3.2 and 3.3 have been broken with a similar error message. Could this be the same issue?

https://github.com/ruby/openssl/actions/runs/11578248737/job/32231644029

C:/hostedtoolcache/windows/Ruby/3.2.5/x64/bin/ruby.exe -I./lib -ropenssl.so [...]
[...]
ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x64-mingw-ucrt]
<internal:C:/hostedtoolcache/windows/Ruby/3.2.5/x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require': 127: The specified procedure could not be found.   - D:/a/openssl/openssl/lib/openssl.so (LoadError)
	from <internal:C:/hostedtoolcache/windows/Ruby/3.2.5/x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
rake aborted!

However, builds with Ruby master don't share the issue even with OpenSSL 3.4.0:

rubyinstaller2: https://github.com/ruby/openssl/actions/runs/11578248737/job/32231645011
ruby-loco/ucrt: https://github.com/ruby/openssl/actions/runs/11578248737/job/32231645466

ruby 3.4.0dev (2024-10-28 master 83568a41af) +PRISM [x64-mingw-ucrt]
OpenSSL::OPENSSL_VERSION: OpenSSL 3.4.0 22 Oct 2024
OpenSSL::OPENSSL_LIBRARY_VERSION: OpenSSL 3.4.0 22 Oct 2024

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Oct 30, 2024

@rhenium

Could this be the same issue?

Yes, it is. Both MSYS2 and MSFT/vcpkg have updated to OpenSSL 3.4.0.

CI is compiling with 3.4.0, but loading 3.3.z dll's. I don't recall seeing a 'policy' statement re OpenSSL 3.y compatibility. Is this a bug in 3.4.0? IIRC, in the past, one could compile with 3.3, and the code would run with 3.2 dlls.

To fix this will require some work in setup-ruby.

Also, is this a Windows specific issue? Obviously, the issue is related to Windows builds including their dll files.

@rhenium
Copy link
Member

rhenium commented Oct 31, 2024

CI is compiling with 3.4.0, but loading 3.3.z dll's. I don't recall seeing a 'policy' statement re OpenSSL 3.y compatibility. Is this a bug in 3.4.0? IIRC, in the past, one could compile with 3.3, and the code would run with 3.2 dlls.

Using a newer OpenSSL version at run time than the compile time is supported, as long as the major version number matches, which is "1.0", "1.1", or "3" for OpenSSL, but downgrading likely isn't.

https://github.com/openssl/general-policies/blob/fa7152227fb5f6b576f78f5197fcd2c401bf029b/policies/versioning-policy.md#minor-release

I haven't been able to reproduce it locally, but if it's what's happening here, it seems like the problem.

Also, is this a Windows specific issue? Obviously, the issue is related to Windows builds including their dll files.

Other CI builds in ruby/openssl should be using the same OpenSSL installation for compiling and testing.

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Oct 31, 2024

Did some more testing. Both Puma & EventMachine compile ext code with OpenSSL. They both passed CI where the Ruby under test bundled 3.3 dlls, but the ext was compiled with 3.4 files.

Puma passed with Ruby master builds (all 3.4), but EventMachine failed.

The issue was with OpenSSL::X509::Request#version=. With OpenSSL 3.3, the values 0, 1, and 2 are accepted. With OpenSSL 3.4, only 0 works. I verified this with the tests in test/openssl/test_x509req.rb.

Also, is this a Windows specific issue? Obviously, the issue is related to Windows builds including their dll files.

Other CI builds in ruby/openssl should be using the same OpenSSL installation for compiling and testing.

Yes. That gets rather messy. I don't recall every trying it on macOS or Ubuntu...

@rhenium
Copy link
Member

rhenium commented Nov 6, 2024

Both Puma & EventMachine compile ext code with OpenSSL. They both passed CI where the Ruby under test bundled 3.3 dlls, but the ext was compiled with 3.4 files.

I think it can happen to work, but nothing guarantees it.

I suspect this is the change causing it to break for ruby/openssl (though I didn't actually verify it - I just found it by git diff openssl-3.3.0 openssl-3.4.0 include/openssl): https://github.com/openssl/openssl/blob/openssl-3.4.0/include/openssl/evp.h#L574

ruby/openssl uses EVP_MD_CTX_size(). In 3.4.0 header, it's redirected to a new function called EVP_MD_CTX_get_size_ex() which doesn't exist in 3.3 or earlier.

The issue was with OpenSSL::X509::Request#version=. With OpenSSL 3.3, the values 0, 1, and 2 are accepted. With OpenSSL 3.4, only 0 works. I verified this with the tests in test/openssl/test_x509req.rb.

This is separate and is due to a behavior change (a stricter error checking) in OpenSSL 3.4. ruby/openssl also had to fix a test case affected by this in #747.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants