Mac M1 Homebrew Perl Carton Net::SSLeay is loading libcrypto in an unsafe way

Viewed 1772

I'm trying to install Net::SSLeay with Carton. The installation fails with this message

Configuring Net-SSLeay-1.90 Running Makefile.PL Do you want to run external tests? 
These tests *will* *fail* if you do not have network connectivity. [n] n 
*** Found LibreSSL-2.8.3 installed in /usr 
*** Be sure to use the same compiler and options to compile your OpenSSL, perl, and Net::SSLeay. Mixing and matching compilers is not supported. 
Checking if your kit is complete... Looks good 
WARNING: /opt/homebrew/Cellar/perl/5.32.1_1/bin/perl is loading libcrypto in an unsafe way -> N/A

I've tried this with system perl, brew perl and multiple perlbrew perls. Google came up with a temp solution to build homebrew using x86_64 architecture. This did work for the libcrypto error, but gave me a whole different set of issues including mysql not running anymore.

Other "solutions" that I've tried are symlinking libssl & libcrypto as suggested by numerous other posts, all sadly without success.

Any ideas how to fix this or work around this without having to reinstall all brew packages as x86_64 ?

Quick Workaround

If you are looking for a quick workaround follow these steps.

  1. Run carton bundle to create a vendor cache directory.
  2. Go to cached tarball 'cache/authors/id/C/CH/CHRISN/' and unpack tar -xvzf Net-SSLeay-1.90.tar.gz
  3. Edit Makefile.PL, change my $prefix = find_openssl_prefix(); to my $prefix = '/opt/homebrew/opt/openssl@1.1'; ** adjust to your openssl location.
  4. Save and create new tarball tar -czvf Net-SSLeay-1.90.tar.gz Net-SSLeay-1.90
  5. Run carton install --cached to use the altered version

Hope this helps anyone in search of workaround

3 Answers

You can solve this in two steps:

  • upgrade ExtUtils::MakeMaker to at least version 7.58 (e.g. cpanm ExtUtils::MakeMaker)
  • install openssl via macports (sudo port install openssl) or homebrew (brew install --cask openssl)

After the Monterey update this broke again also on the x86_64 architecture, but just symlinking your latest openssl (where ever it is, depending how you have installed it) seemed to fix this. Example:

$ export OPENSSL_PREFIX=[find your openssl installation]
$ sudo ln -s $OPENSSL_PREFIX/lib/libssl.dylib /usr/local/lib/
$ sudo ln -s $OPENSSL_PREFIX/lib/libcrypto.dylib /usr/local/lib/

Better workaround:

I entered export OPENSSL_PREFIX=/opt/homebrew/opt/openssl@1.1 in my shell and then ran cpan. I checked the code in Makefile.PL and the first thing the function find_openssl_prefix does is to check the OPENSSL_PREFIX environment variable. If it is set, then it the function will return its contents.

Add the variable to your .profile, .cshrc, .bashrc, .zshrc, or whatever rc file your shell uses and you never have to worry about it again!!

Related