Bug #19289 5.0.21 breaks PHP's openssl functionality
Submitted: 23 Apr 2006 22:05 Modified: 13 Sep 2006 12:44
Reporter: Jordan Russell Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.24 OS:Linux (Linux (Fedora Core 5))
Assigned to: CPU Architecture:Any

[23 Apr 2006 22:05] Jordan Russell
Description:
Installing MySQL-shared-5.0.20a-0.glibc23.i386.rpm causes the OpenSSL functionality in PHP to fail with error messages. Simply downgrading MySQL-shared from 5.0.20a to 5.0.20 solves the problem.

I assume this has something to do with the SSL-related changes in MySQL 5.0.20a; somehow it's not playing nice with PHP's own SSL support.

How to repeat:
1. Install (or downgrade to) the 5.0.20 devel and shared packages:

# rpm -Uvh --oldpackage MySQL-{devel,shared}-5.0.20-0.glibc23.i386.rpm

2. Download PHP 5.1.2 and build it as follows:

# ./configure --with-mysql --with-openssl
# make
# make install
# make install-cli

3. Create a file named "testssl.php" with the following contents:

<?php
$f = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if ($f) echo("Success!\n");
?>

4. Run "testssl.php" from the command line -- it works:

# /usr/local/bin/php testssl.php
Success!

5. Upgrade to the 5.0.20a shared package:

# rpm -Uvh MySQL-shared-5.0.20a-0.glibc23.i386.rpm

6. Run "testssl.php" again -- this time we get a bunch of OpenSSL errors, even though all we did was upgrade the MySQL-shared package:

# /usr/local/bin/php testssl.php
Warning: fsockopen(): SSL operation failed with code 114. OpenSSL Error messages:
error:00000000:lib(0):func(0):reason(0) in testssl.php on line 2

Warning: fsockopen(): Failed to enable crypto in testssl.php on line 2

Warning: fsockopen(): unable to connect to ssl://www.paypal.com:443 (Unknown error) in testssl.php on line 2

7. Downgrade to 5.0.20 and test again:

# rpm -Uvh --oldpackage MySQL-shared-5.0.20-0.glibc23.i386.rpm
# /usr/local/bin/php testssl.php
Success!
[24 Apr 2006 6:42] Valeriy Kravchuk
Thank you for a problem report. Please, try to rebuild PHP after installation of 5.0.20a:

./configure --with-mysql --with-openssl
make
make install
make install-cli

and then try your test again. Inform about the results.
[24 Apr 2006 7:29] Jordan Russell
Rebuilding PHP from scratch after installing 5.0.20a does not help. Same errors.
[2 May 2006 1:18] Jordan Russell
Same problem with MySQL-shared-5.0.21-0.glibc23.i386.rpm, even if PHP is rebuilt after upgrading to 5.0.21. 

BTW, this is reproducible with a fresh install of Fedora Core 5 using the steps I provided.
[23 Jun 2006 14:41] Valeriy Kravchuk
I believe, bug #19575 explains the real reason for this one (and yes, I was able to repeat with 5.0.22 and PHP 5.1.4, but with a Segmentation Fault in /usr/local/bin/php in case both --with-mysql and --with-openssl are included. If only one of this options is included, everything just works as expected).

So, I'll mark this as a duplicate of bug #19575. Check with 5.0.23, when it will be released officially, and reopen this bug report if you'll be able to repeat this problem.
[5 Aug 2006 17:23] Jordan Russell
There is still a problem with 5.0.24. Now, instead of displaying warnings, PHP segfaults when fsockopen() is called.

Here is the script I'm using to test:

<?php
echo "Before fsockopen call\n";
$f = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
echo "After fsockopen call\n";
?>

I saved it as "z.php", and tested it by running "/usr/local/bin/php z.php".

With 5.0.20 installed, it outputs:

Before fsockopen call
After fsockopen call

With 5.0.21 installed, it outputs:

Before fsockopen call
Warning: fsockopen(): SSL operation failed with code 114. OpenSSL Error messages:
error:00000000:lib(0):func(0):reason(0) in /root/z.php on line 3
Warning: fsockopen(): Failed to enable crypto in /root/z.php on line 3
Warning: fsockopen(): unable to connect to ssl://www.paypal.com:443 (Unknown error) in /root/z.php on line 3
After fsockopen call

With 5.0.24 installed, it outputs:

Before fsockopen call
Segmentation fault

Rebuilding PHP (the same way as before) after installing the 5.0.24 packages did not help.
[30 Aug 2006 12:03] Marcus Bointon
I'm seeing this same problem on MacOS X with MySQL 5.0.24 binaries and PHP 5.1.5. If I compile PHP without either MySQL or OpenSSL, all works fine, but with them both enabled, I get these errors:

/usr/bin/ld: warning multiple definitions of symbol _BN_bin2bn
/usr/local/mysql/lib/libmysqlclient.a(ssl.o) definition of _BN_bin2bn in section (__TEXT,__text)/sw/lib/libcrypto.dylib(bn_lib.o) definition of _BN_bin2bn
/usr/bin/ld: warning multiple definitions of symbol _SSLv3_client_method
/usr/local/mysql/lib/libmysqlclient.a(ssl.o) definition of _SSLv3_client_method in section (__TEXT,__text)
/sw/lib/libssl.dylib(s3_clnt.o) definition of _SSLv3_client_method
/usr/bin/ld: warning multiple definitions of symbol _TLSv1_client_method
/usr/local/mysql/lib/libmysqlclient.a(ssl.o) definition of _TLSv1_client_method in section (__TEXT,__text)
/sw/lib/libssl.dylib(t1_clnt.o) definition of _TLSv1_client_method
/usr/bin/ld: multiple definitions of symbol _CRYPTO_add_lock
/sw/lib/libcrypto.dylib(cryptlib.o) definition of _CRYPTO_add_lock
/usr/local/mysql/lib/libmysqlclient.a(libtaocrypt_la-misc.o) definition of _CRYPTO_add_lock in section (__TEXT,__text)
/usr/bin/ld: multiple definitions of symbol _CRYPTO_lock
/sw/lib/libcrypto.dylib(cryptlib.o) definition of _CRYPTO_lock
/usr/local/mysql/lib/libmysqlclient.a(libtaocrypt_la-misc.o) definition of _CRYPTO_lock in section (__TEXT,__text)
/usr/bin/ld: warning multiple definitions of symbol _locale_charset
/sw/lib/libiconv.dylib(localcharset.o) definition of _locale_charset
/sw/lib/libintl.dylib(localcharset.o) definition of _locale_charset
/usr/bin/ld: warning multiple definitions of symbol _regcomp
/usr/sbin/httpd definition of _regcomp
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libm.dylib(regcomp.So) definition of _regcomp
/usr/bin/ld: warning multiple definitions of symbol _regexec
/usr/sbin/httpd definition of _regexec
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libm.dylib(regexec.So) definition of _regexec
/usr/bin/ld: warning multiple definitions of symbol _regfree
/usr/sbin/httpd definition of _regfree
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libm.dylib(regfree.So) definition of _regfree
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1

Hopefully this will shed more light on the problem.
[12 Sep 2006 18:16] [ name withheld ]
This configuration results in the same error:

# OpenSSL installation 
cd ..
rm -rf openssl-0.9.8c
tar zxf ../upgrade/openssl-0.9.8c.tar.gz
cd openssl-0.9.8c
./config shared --prefix=/usr/local --openssldir=/usr/local
make
make install

## MySQL installation
tar zxf \
/root/src/upgrade/mysql-standard-5.0.24a-linux-i686-glibc23.tar.gz
ln -s mysql-standard-5.0.24a-linux-i686-glibc23 mysql
ln -s mysql mysql5
/etc/rc.d/rc.mysqld start
cd mysql/bin
mysqlcheck --check-upgrade --all-databases --auto-repair -p
mysql_fix_privilege_tables

# PHP installation
tar jxf ../upgrade/php-5.1.6.tar.bz2
cd php-5.1.6
./configure \
--prefix=/usr/local/apache2/php5 \
--sysconfdir=/usr/local/apache2/conf \
--with-config-file-path=/usr/local/apache2/conf \
--without-apache \
--with-mysql=/usr/local/mysql \
--with-zlib --with-gdbm --with-gettext \
--enable-ftp --enable-calendar --enable-bcmath --with-bz2 \
--with-openssl --enable-xml --with-mm=../mm-1.4.0 \
--enable-memory-limit --enable-zend-multibyte \
--with-gd --with-mcrypt --with-mhash --with-ncurses \
--with-png-dir=/usr/local --with-jpeg-dir=/usr/local \
--with-freetype-dir=/usr/local --with-zlib-dir=/usr/local \
--enable-sockets --with-ttf \
--disable-cli --enable-cgi --without-iconv
make
make install

Installed on Slackware 9.1
[13 Sep 2006 12:44] Domas Mituzas
This is duplicate of bug#21930, fixed in 5.0.25 and 5.1.12