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

Use custom OpenSSL libs for OpenSSLDSOPatch #1186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SerheyDolgushev
Copy link
Contributor

I had a funny case recently:

  • Have already installed php-7.3.6, which uses OpenSSL 1.0.2s:

    $ ls -l /usr/local/opt/openssl
    XXX  24 Jun  9 20:58 /usr/local/opt/openssl -> ../Cellar/openssl/1.0.2s
    
  • Wanted to install php-7.4.6, which requires OpenSSL 1.1.1g. I was getting following errors during the build when OpenSSL 1.0.2s was used:

    Undefined symbols for architecture x86_64:
      "_ASN1_STRING_get0_data", referenced from:
          _zif_openssl_spki_export_challenge in openssl.o
          _php_openssl_add_assoc_name_entry in openssl.o
          _php_openssl_asn1_time_to_time_t in openssl.o
          _openssl_x509v3_subjectAltName in openssl.o
      "_BN_is_zero", referenced from:
          _php_openssl_pkey_init_dsa in openssl.o
      "_BN_with_flags", referenced from:
          _php_openssl_dh_pub_from_priv in openssl.o
    

I wasn't able just to update /usr/local/opt/openssl as it was breaking my current php-7.3.6. So I compiled OpenSSL 1.0.2s at /usr/local/openssl/1.1.1g, and was using export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/openssl/1.1.1g/lib/pkgconfig before phpbrew install... call. But it still was causing the same error during the build. After some debugging I found out that OpenSSLDSOPatch is causing it.

So this PR allows to:
Use custom OpenSSL libs for OpenSSLDSOPatch, they just need to be linked to /usr/local/opt/phpbrew/openssl/lib. And maybe it worth to add some notice message when this patch is applied?

@SerheyDolgushev
Copy link
Contributor Author

Ping @morozov (sorry, if you are the wrong person, I saw your name in the latest commits).

@morozov
Copy link
Contributor

morozov commented Jul 20, 2020

Ping @morozov (sorry, if you are the wrong person, I saw your name in the latest commits).

If you mean 01de86c, it's just a code formatting change. I never modified this patch or used it myself.

After some debugging I found out that OpenSSLDSOPatch is causing it.

Would it make sense to just disable the patch in this case? As far as I understand, even with this change, your case requires some trickery.

I wasn't able just to update /usr/local/opt/openssl as it was breaking my current php-7.3.6. So I compiled OpenSSL 1.0.2s at /usr/local/openssl/1.1.1g

If you want to use multiple library versions for multiple PHP versions, should you be building PHP against a specific OpenSSL version, not just /usr/local/opt/openssl?

Also, according to php/php-src#2667 (comment), it should be possible to build PHP 7.3 against OpenSSL 1.1 and it actually is possible in my case:

$ php -v
PHP 7.3.20 (cli) (built: Jul 18 2020 08:55:10) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.20, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

$ apt policy libssl-dev
libssl-dev:
  Installed: 1.1.1f-1ubuntu2
  Candidate: 1.1.1f-1ubuntu2
  Version table:
 *** 1.1.1f-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status

$ php -r 'echo OPENSSL_VERSION_TEXT;'
OpenSSL 1.1.1f  31 Mar 2020

Why do you need to use multiple OpenSSL versions at a time?

@frankli0324
Copy link

frankli0324 commented Dec 26, 2021

homebrew had upgraded openssl to 3.x, and php doesn't build with that currently. I need to use openssl@1.1 for building php while not breaking other things that rely on /usr/local/opt/openssl, and I ran into the same scenario.

@SerheyDolgushev
Copy link
Contributor Author

homebrew had upgraded openssl to 3.x, and php doesn't build with that currently. I need to use openssl@1.1 for building php while not breaking other things that rely on /usr/local/opt/openssl, and I ran into the same scenario.

I can confirm I had the same issues with https://formulae.brew.sh/formula/openssl@3 last week. So the easiest way to reproduce this issues is:

  1. Install openssl@1.1 brew package.
  2. Install openssl@3 brew package.
  3. Try to install PHP 8.1.1 using phpbrew: php -d memory_limit=-1 phpbrew -d install 8.1.1 +default

And instead of getting installed PHP 8.1.1, you will get an OpenSSL error message.

@SerheyDolgushev
Copy link
Contributor Author

homebrew had upgraded openssl to 3.x, and php doesn't build with that currently. I need to use openssl@1.1 for building php while not breaking other things that rely on /usr/local/opt/openssl, and I ran into the same scenario.

I can confirm I had the same issues with https://formulae.brew.sh/formula/openssl@3 last week. So the easiest way to reproduce this issues is:

  1. Install openssl@1.1 brew package.
  2. Install openssl@3 brew package.
  3. Try to install PHP 8.1.1 using phpbrew: php -d memory_limit=-1 phpbrew -d install 8.1.1 +default

And instead of getting installed PHP 8.1.1, you will get an OpenSSL error message.

@jhdxr can you please have a look at this one?

@nicodemuz
Copy link

I belive I'm having a very similar issue, see #1274

@theofidry
Copy link
Contributor

The OpenSSL version error is caused by using the wrong OpenSSL version. Unfortunately the PHP compilation is quite bad in terms of requirement communication, and PHPBrew has nothing for it either.

You can specify the version you desire like so:

phpbrew -d install 8.1.1 +default +openssl="$(brew --prefix openssl@1.1)"

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

Successfully merging this pull request may close these issues.

None yet

5 participants