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

Problem with libcrypto on MacOS 11 (Big Sur) #81

Open
zaucker opened this issue Dec 2, 2020 · 13 comments
Open

Problem with libcrypto on MacOS 11 (Big Sur) #81

zaucker opened this issue Dec 2, 2020 · 13 comments

Comments

@zaucker
Copy link

zaucker commented Dec 2, 2020

WARNING: /Users/zaucker/opt/rakudo-2020.10/bin/rakudo is loading libcrypto in an unsafe way
See also raku-community-modules/IO-Socket-Async-SSL#60

@tgt
Copy link

tgt commented Feb 21, 2021

I don't know much about this sort of thing, but I've had a little look and it seems that the issue is using dlopen to open an unversioned libcrypto under macOS Big Sur's new dynamic linker cache.

Using dlopen("libssl.dylib", RTLD_NOW | RTLD_GLOBAL) results in <program> is loading libcrypto in an unsafe way, whilst using dlopen("libssl.46.dylib", RTLD_NOW | RTLD_GLOBAL) works as expected. Big Sur no longer includes dylibs in /usr/lib/ so I used otool -L /usr/bin/openssl to see which version to load. I used Hopper to check for the error string in libssl.46.dylib and libssl.42.dylib (the latest version on macOS Catalina) and it only appears in the former.

Hardcoding a version into OpenSSL/NativeLib.pm6 would “solve” this in an extremely fragile way, but Apple doesn't support using the libraries provided with the system and hasn't since 2011.

Symlinking versions of libssl and libcrypto installed using Homebrew into /usr/local/lib fixes the issue, but I don't know what problems that could cause and it creates additional friction for users.

ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/lib/libssl.dylib
ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/lib/libcrypto.dylib

Is it possible for sergot/OpenSSL to specify a dependency on OpenSSL and then build, install and link with that version somehow?

Is there anything else I should try?

(I found this issue via rakudo/rakudo#4112 and raku-community-modules/IO-Socket-Async-SSL#60)

@zaucker
Copy link
Author

zaucker commented Feb 21, 2021

Symlinking versions of libssl and libcrypto installed using Homebrew into /usr/local/lib fixes the issue, but I don't know what problems that could cause and creates additional friction for users.

ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/lib/libssl.dylib
ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/lib/libcrypto.dylib

Thanks, just tried this successfully.

@skaji
Copy link
Contributor

skaji commented May 7, 2021

I think this issue has been resolved.

@lizmat
Copy link

lizmat commented Oct 14, 2021

@skaji
Copy link
Contributor

skaji commented Oct 14, 2021

brew's openssl is now an alias of openssl@3,
while the macos environment of github action has [email protected] only.

So you need to

  • install openssl@3 (i.e., brew install openssl), or
  • execute zef with OPENSSL_PREFIX=$(brew --prefix --installed [email protected])

@lizmat
Copy link

lizmat commented Oct 14, 2021

@skaji so how would that translate to .github/workflows/test.yml ? As I don't see a way to do something MacOS specific there, and brew only exists on MacOS (presumably). Case in question: https://github.com/lizmat/App-IRC-Log/blob/main/.github/workflows/test.yml

@skaji
Copy link
Contributor

skaji commented Oct 14, 2021

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 8e5a019..2927799 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -24,6 +24,8 @@ jobs:
       - uses: Raku/setup-raku@v1
         with:
           raku-version: ${{ matrix.raku-version }}
+      - if: matrix.os == 'macOS-latest'
+        run: brew install openssl
       - name: Install Dependencies
         run: zef -v install --/test --test-depends --deps-only .
       - name: Run Tests

@lizmat
Copy link

lizmat commented Oct 14, 2021

@skaji Thank you very much, that did the trick! :-)

@sullerandras
Copy link

I ran into this issue on Macos 12 (Monterey). There was no /usr/local/lib folder on my computer, and i use asdf to install ruby, so i believe these are the commands that i executed to make it work:

sudo mkdir /usr/local/lib
sudo ln -s /Users/andras/.asdf/installs/ruby/2.7.5/openssl/lib/libssl.1.1.dylib /usr/local/lib/libssl.1.1.dylib
sudo ln -s /Users/andras/.asdf/installs/ruby/2.7.5/openssl/lib/libssl.1.1.dylib /usr/local/lib/libssl.dylib

Not sure what will happen if i need to install other ruby versions, but so far it works fine.

@jubilatious1
Copy link

#102

@alabamenhu
Copy link

For those who are still having this issue, on my M2 with Sonoma:

brew install openssl
sudo ln -s /opt/homebrew/Cellar/openssl@3/3.4.0/lib/libssl.3.dylib    /usr/local/lib/libssl.3.dylib
sudo ln -s /opt/homebrew/Cellar/openssl@3/3.4.0/lib/libssl.dylib      /usr/local/lib/libssl.dylib
sudo ln -s /opt/homebrew/Cellar/openssl@3/3.4.0/lib/libcrypto.3.dylib /usr/local/lib/libcrypto.3.dylib
sudo ln -s /opt/homebrew/Cellar/openssl@3/3.4.0/lib/libcrypto.dylib   /usr/local/lib/libcrypto.dylib
zef install OpenSSL

@lizmat
Copy link

lizmat commented Oct 27, 2024

See dynamic libraries on MacOS

Also see: MacOS::NativeLib

@alabamenhu
Copy link

See dynamic libraries on MacOS

Also see: MacOS::NativeLib

I assumed it was related although my initial attempt at patching in MacOS::NativeLib didn't work. I'll try looking at it more when I'm not on a time crunch to see if it can be done, or modifying the build script somehow. Cro is one of the major frameworks for Raku and it relies on the OpenSSL module heavily, so ideally I can figure out something that will work out of the box more often than not to patch in.

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

No branches or pull requests

7 participants