PHP 5.2.17 on Debian Wheezy 7: Solve make error in xp_ssl.c

Written by - 0 comments

Published on - Listed in PHP Linux


When I tried to compile PHP 5.2.17 (I know, I know, it's EOL!) on a Debian Wheezy machine, 'make' ends with the following error message:

 ext/openssl/.libs/xp_ssl.o: In function `php_openssl_setup_crypto':
/root/downloads/php-5.2.17/ext/openssl/xp_ssl.c:337: undefined reference to `SSLv2_client_method'
/root/downloads/php-5.2.17/ext/openssl/xp_ssl.c:357: undefined reference to `SSLv2_server_method'
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

According to PHP bug #54736, this is because the new Debian system has a newer libssl without SSLv2 support.

To still be able to finish the compile process, I needed to manually apply the following patch:

--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -328,10 +328,12 @@ static inline int php_openssl_setup_cryp
             sslsock->is_client = 1;
             method = SSLv23_client_method();
             break;
+#ifndef OPENSSL_NO_SSL2
         case STREAM_CRYPTO_METHOD_SSLv2_CLIENT:
             sslsock->is_client = 1;
             method = SSLv2_client_method();
             break;
+#endif
         case STREAM_CRYPTO_METHOD_SSLv3_CLIENT:
             sslsock->is_client = 1;
             method = SSLv3_client_method();
@@ -348,10 +350,12 @@ static inline int php_openssl_setup_cryp
             sslsock->is_client = 0;
             method = SSLv3_server_method();
             break;
+#ifndef OPENSSL_NO_SSL2
         case STREAM_CRYPTO_METHOD_SSLv2_SERVER:
             sslsock->is_client = 0;
             method = SSLv2_server_method();
             break;
+#endif
         case STREAM_CRYPTO_METHOD_TLS_SERVER:
             sslsock->is_client = 0;
             method = TLSv1_server_method();
@@ -629,9 +633,11 @@ static inline int php_openssl_tcp_sockop
                 case STREAM_CRYPTO_METHOD_SSLv23_CLIENT:
                     sock->method = STREAM_CRYPTO_METHOD_SSLv23_SERVER;
                     break;
+#ifndef OPENSSL_NO_SSL2
                 case STREAM_CRYPTO_METHOD_SSLv2_CLIENT:
                     sock->method = STREAM_CRYPTO_METHOD_SSLv2_SERVER;
                     break;
+#endif
                 case STREAM_CRYPTO_METHOD_SSLv3_CLIENT:
                     sock->method = STREAM_CRYPTO_METHOD_SSLv3_SERVER;
                     break;
@@ -911,9 +917,11 @@ php_stream *php_openssl_ssl_socket_facto
     if (strncmp(proto, "ssl", protolen) == 0) {
         sslsock->enable_on_connect = 1;
         sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
+#ifndef OPENSSL_NO_SSL2
     } else if (strncmp(proto, "sslv2", protolen) == 0) {
         sslsock->enable_on_connect = 1;
         sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT;
+#endif
     } else if (strncmp(proto, "sslv3", protolen) == 0) {
         sslsock->enable_on_connect = 1;
         sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT;

I saved it as xp_ssl.patch and applied it on xp_ssl.c:

patch xp_ssl.c xp_ssl.patch
patching file xp_ssl.c
Hunk #1 succeeded at 332 (offset 4 lines).
Hunk #2 succeeded at 354 (offset 4 lines).
Hunk #3 succeeded at 583 (offset -50 lines).
Hunk #4 succeeded at 819 (offset -98 lines).

The diff looked like this:

diff xp_ssl.c xp_ssl.c.orig
335d334
< #ifndef OPENSSL_NO_SSL2
340d338
< #endif
357d354
< #ifndef OPENSSL_NO_SSL2
362d358
< #endif
586d581
< #ifndef OPENSSL_NO_SSL2
590d584
< #endif
822d815
< #ifndef OPENSSL_NO_SSL2
826d818
< #endif

Right after I launched make again and received this error:

/usr/bin/ld: cannot find -lltdl
collect2: error: ld returned 1 exit status
make: *** [libphp5.la] Error 1

Well that was a bit easier to solve as it was only a package missing:

apt-get install libltdl-dev libltdl7

After that, make worked as it should:

make
[...]
Build complete.
Don't forget to run 'make test'.


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder