Bug #74378 [Com]: Compilation with OPENSSL_API_COMPAT >= 0x10100000L fails
| From: | pgnet dot dev at gmail dot com | Date: | Thu, 06 Apr 2017 15:40:59 +0000 |
| Subject: | Bug #74378 [Com]: Compilation with OPENSSL_API_COMPAT >= 0x10100000L fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208368@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74378&edit=1
ID: 74378
Comment by: pgnet dot dev at gmail dot com
Reported by: pgnet dot dev at gmail dot com
Summary: Compilation with OPENSSL_API_COMPAT >= 0x10100000L
fails
Status: Open
Type: Bug
Package: OpenSSL related
Operating System: any
PHP Version: master-Git-2017-04-05 (Git)
Block user comment: N
Private report: N
New Comment:
applying to php head
git log | head
commit 67136fe77b24e59b185775ec308d81235666aaf9
Author: Remi Collet <remi@php.net>
Date: Wed Apr 5 07:39:39 2017 +0200
zip ext is 1.14.0
commit 3c750d91ee9eeba00563a7a2d94a7470406b1b7e
Author: Anatol Belski <ab@php.net>
Date: Tue Apr 4 16:32:29 2017 +0200
this patch
--- /work/php-head/ext/openssl/openssl.c.ORIG 2017-04-06 08:25:56.483452012 -0700
+++ /work/php-head/ext/openssl/openssl.c 2017-04-06 08:26:01.507431152 -0700
@@ -1399,10 +1399,10 @@
le_x509 = zend_register_list_destructors_ex(php_x509_free, NULL, "OpenSSL X.509",
module_number);
le_csr = zend_register_list_destructors_ex(php_csr_free, NULL, "OpenSSL X.509 CSR",
module_number);
- SSL_library_init();
- OpenSSL_add_all_ciphers();
- OpenSSL_add_all_digests();
- OpenSSL_add_all_algorithms();
+ OPENSSL_init_ssl(0, NULL);
+ /* OpenSSL_add_all_ciphers(); */
+ /* OpenSSL_add_all_digests(); */
+ /* OpenSSL_add_all_algorithms(); */
#if !defined(OPENSSL_NO_AES) && defined(EVP_CIPH_CCM_MODE) &&
OPENSSL_VERSION_NUMBER < 0x100020000
EVP_add_cipher(EVP_aes_128_ccm());
@@ -1410,7 +1410,7 @@
EVP_add_cipher(EVP_aes_256_ccm());
#endif
- SSL_load_error_strings();
+ /* SSL_load_error_strings(); */
/* register a resource id number with OpenSSL so that we can map SSL -> stream structures in
* OpenSSL callbacks */
@@ -1562,7 +1562,7 @@
{
php_info_print_table_start();
php_info_print_table_row(2, "OpenSSL support", "enabled");
- php_info_print_table_row(2, "OpenSSL Library Version", SSLeay_version(SSLEAY_VERSION));
+ php_info_print_table_row(2, "OpenSSL Library Version",
OpenSSL_version(OPENSSL_VERSION));
php_info_print_table_row(2, "OpenSSL Header Version", OPENSSL_VERSION_TEXT);
php_info_print_table_row(2, "Openssl default config", default_ssl_conf_filename);
php_info_print_table_end();
@@ -1574,12 +1574,12 @@
*/
PHP_MSHUTDOWN_FUNCTION(openssl)
{
- EVP_cleanup();
+ /* EVP_cleanup(); */
/* prevent accessing locking callback from unloaded extension */
- CRYPTO_set_locking_callback(NULL);
+ /* CRYPTO_set_locking_callback(NULL); */
/* free allocated error strings */
- ERR_free_strings();
+ /* ERR_free_strings(); */
php_unregister_url_stream_wrapper("https");
php_unregister_url_stream_wrapper("ftps");
changes to openssl 1.1 init, gets rid of deprecated calls, and allows a 'successful' (no
errors) build of php + openssl ext
ldd openssl.so
linux-vdso.so.1 (0x00007fff749a3000)
libssl.so.1.1 => /usr/local/openssl11/lib64/libssl.so.1.1 (0x00007f30afb26000)
libcrypto.so.1.1 => /usr/local/openssl11/lib64/libcrypto.so.1.1 (0x00007f30af67c000)
libc.so.6 => /lib64/libc.so.6 (0x00007f30af278000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f30af074000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f30aee56000)
/lib64/ld-linux-x86-64.so.2 (0x000055636f465000)
php -v
PHP 7.2.0-dev (cli) (built: Apr 6 2017 08:31:10) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.2.0-dev, Copyright (c) 1999-2017, by Zend Technologies
php -i | egrep -i ^openssl | grep Version
OpenSSL Library Version => OpenSSL 1.1.0e 16 Feb 2017
OpenSSL Header Version => OpenSSL 1.1.0e 16 Feb 2017
note, of course, this completely ignores the necessary conditionals for keeping openssl 10x compat
and, it remains as yet untested beyond this initial exec
Previous Comments:
------------------------------------------------------------------------
[2017-04-05 20:44:39] pgnet dot dev at gmail dot com
Description:
------------
With php HEAD, build on linux64 + openssl 1.1 (./config --api=1.1.0 ...) currently FAILS.
[referred from:
Bug #72360 ext/openssl build failure with OpenSSL 1.1.0
https://bugs.php.net/bug.php?id=72360&edit=2
]
Actual result:
--------------
[referred from:
Bug #72360 ext/openssl build failure with OpenSSL 1.1.0
https://bugs.php.net/bug.php?id=72360&edit=2
]
With php HEAD
cd /work/php-src
git clean -xfd
git reset --hard HEAD
git checkout master
git log | head
nominally *requires* this fix
perl -pi -e '\
s|SSLeay_version\(SSLEAY_VERSION\)|OpenSSL_version\(OPENSSL_VERSION\)|g' \
/work/php-src/ext/openssl/openssl.c
then, with simple config
export PHP_RPATHS="/usr/local/openssl11/lib64"
./buildconf --force
./configure \
--disable-all \
--with-openssl=/usr/local/openssl11
builds, with lots of warnings, but no apparent errors
make V=1
/bin/sh /work/php-src/libtool --silent --preserve-dup-deps --mode=compile /usr/bin/gcc-6
-Iext/openssl/ -I/work/php-src/ext/openssl/ -DPHP_ATOM_INC -I/work/php-src/include
-I/work/php-src/main -I/work/php-src -I/work/php-src/ext/date/lib -I/usr/local/openssl11/include
-I/work/php-src/TSRM -I/work/php-src/Zend -O3 -Wall -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native
-fPIC -DPIC -D_GNU_SOURCE -fno-strict-aliasing -fvisibility=hidden -DZEND_SIGNALS -c
/work/php-src/ext/openssl/openssl.c -o ext/openssl/openssl.lo
/work/php-src/ext/openssl/openssl.c: In function âadd_assoc_name_entryâ:
/work/php-src/ext/openssl/openssl.c:859:13: warning: implicit declaration of function
âASN1_STRING_dataâ [-Wimplicit-function-declaration]
to_add = ASN1_STRING_data(str);
^~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:859:11: warning: assignment makes pointer from integer without
a cast [-Wint-conversion]
to_add = ASN1_STRING_data(str);
^
/work/php-src/ext/openssl/openssl.c: In function âasn1_time_to_time_tâ:
/work/php-src/ext/openssl/openssl.c:921:28: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
if (timestr_len != strlen((const char*)ASN1_STRING_data(timestr))) {
^
In file included from /work/php-src/Zend/zend.h:31:0,
from /work/php-src/main/php.h:35,
from /work/php-src/ext/openssl/openssl.c:30:
/work/php-src/ext/openssl/openssl.c:936:19: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
strbuf = estrdup((char *)ASN1_STRING_data(timestr));
^
/work/php-src/Zend/zend_alloc.h:172:36: note: in definition of macro âestrdupâ
#define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
^
/work/php-src/ext/openssl/openssl.c: In function âzm_startup_opensslâ:
/work/php-src/ext/openssl/openssl.c:1402:2: warning: implicit declaration of function
âSSL_library_initâ [-Wimplicit-function-declaration]
SSL_library_init();
^~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:1403:2: warning: implicit declaration of function
âOpenSSL_add_all_ciphersâ [-Wimplicit-function-declaration]
OpenSSL_add_all_ciphers();
^~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:1404:2: warning: implicit declaration of function
âOpenSSL_add_all_digestsâ [-Wimplicit-function-declaration]
OpenSSL_add_all_digests();
^~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:1405:2: warning: implicit declaration of function
âOpenSSL_add_all_algorithmsâ [-Wimplicit-function-declaration]
OpenSSL_add_all_algorithms();
^~~~~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:1413:2: warning: implicit declaration of function
âSSL_load_error_stringsâ [-Wimplicit-function-declaration]
SSL_load_error_strings();
^~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c: In function âzm_shutdown_opensslâ:
/work/php-src/ext/openssl/openssl.c:1577:2: warning: implicit declaration of function
âEVP_cleanupâ [-Wimplicit-function-declaration]
EVP_cleanup();
^~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:1580:2: warning: implicit declaration of function
âCRYPTO_set_locking_callbackâ [-Wimplicit-function-declaration]
CRYPTO_set_locking_callback(NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:1582:2: warning: implicit declaration of function
âERR_free_stringsâ [-Wimplicit-function-declaration]
ERR_free_strings();
^~~~~~~~~~~~~~~~
In file included from /work/php-src/main/php.h:39:0,
from /work/php-src/ext/openssl/openssl.c:30:
/work/php-src/ext/openssl/openssl.c: In function âzif_openssl_spki_export_challengeâ:
/work/php-src/ext/openssl/openssl.c:2045:16: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
RETVAL_STRING((char *) ASN1_STRING_data(spki->spkac->challenge));
^
/work/php-src/Zend/zend_API.h:592:21: note: in definition of macro âZVAL_STRINGâ
const char *_s = (s); \
^
/work/php-src/ext/openssl/openssl.c:2045:2: note: in expansion of macro âRETVAL_STRINGâ
RETVAL_STRING((char *) ASN1_STRING_data(spki->spkac->challenge));
^~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c: In function âopenssl_x509v3_subjectAltNameâ:
/work/php-src/ext/openssl/openssl.c:2236:20: warning: passing argument 2 of âBIO_writeâ
makes pointer from integer without a cast [-Wint-conversion]
BIO_write(bio, ASN1_STRING_data(as),
^~~~~~~~~~~~~~~~
In file included from /usr/local/openssl11/include/openssl/err.h:21:0,
from /work/php-src/ext/openssl/php_openssl.h:49,
from /work/php-src/ext/openssl/openssl.c:32:
/usr/local/openssl11/include/openssl/bio.h:549:5: note: expected âconst void *â but
argument is of type âintâ
int BIO_write(BIO *b, const void *data, int len);
^~~~~~~~~
/work/php-src/ext/openssl/openssl.c:2242:20: warning: passing argument 2 of âBIO_writeâ
makes pointer from integer without a cast [-Wint-conversion]
BIO_write(bio, ASN1_STRING_data(as),
^~~~~~~~~~~~~~~~
In file included from /usr/local/openssl11/include/openssl/err.h:21:0,
from /work/php-src/ext/openssl/php_openssl.h:49,
from /work/php-src/ext/openssl/openssl.c:32:
/usr/local/openssl11/include/openssl/bio.h:549:5: note: expected âconst void *â but
argument is of type âintâ
int BIO_write(BIO *b, const void *data, int len);
^~~~~~~~~
/work/php-src/ext/openssl/openssl.c:2248:20: warning: passing argument 2 of âBIO_writeâ
makes pointer from integer without a cast [-Wint-conversion]
BIO_write(bio, ASN1_STRING_data(as),
^~~~~~~~~~~~~~~~
In file included from /usr/local/openssl11/include/openssl/err.h:21:0,
from /work/php-src/ext/openssl/php_openssl.h:49,
from /work/php-src/ext/openssl/openssl.c:32:
/usr/local/openssl11/include/openssl/bio.h:549:5: note: expected âconst void *â but
argument is of type âintâ
int BIO_write(BIO *b, const void *data, int len);
^~~~~~~~~
/work/php-src/ext/openssl/openssl.c: In function âzif_openssl_x509_parseâ:
/work/php-src/ext/openssl/openssl.c:2340:52: warning: implicit declaration of function
âX509_get_notBeforeâ [-Wimplicit-function-declaration]
add_assoc_asn1_string(return_value, "validFrom", X509_get_notBefore(cert));
^~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:2340:52: warning: passing argument 3 of
âadd_assoc_asn1_stringâ makes pointer from integer without a cast [-Wint-conversion]
/work/php-src/ext/openssl/openssl.c:892:13: note: expected âASN1_STRING * {aka struct
asn1_string_st *}â but argument is of type âintâ
static void add_assoc_asn1_string(zval * val, char * key, ASN1_STRING * str) /* {{{ */
^~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:2341:51: warning: implicit declaration of function
âX509_get_notAfterâ [-Wimplicit-function-declaration]
add_assoc_asn1_string(return_value, "validTo", X509_get_notAfter(cert));
^~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:2341:51: warning: passing argument 3 of
âadd_assoc_asn1_stringâ makes pointer from integer without a cast [-Wint-conversion]
/work/php-src/ext/openssl/openssl.c:892:13: note: expected âASN1_STRING * {aka struct
asn1_string_st *}â but argument is of type âintâ
static void add_assoc_asn1_string(zval * val, char * key, ASN1_STRING * str) /* {{{ */
^~~~~~~~~~~~~~~~~~~~~
In file included from /work/php-src/main/php.h:39:0,
from /work/php-src/ext/openssl/openssl.c:30:
/work/php-src/ext/openssl/openssl.c:2343:72: warning: passing argument 1 of
âasn1_time_to_time_tâ makes pointer from integer without a cast [-Wint-conversion]
add_assoc_long(return_value, "validFrom_time_t",
asn1_time_to_time_t(X509_get_notBefore(cert)));
^
/work/php-src/Zend/zend_API.h:413:90: note: in definition of macro âadd_assoc_longâ
define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
^~~
/work/php-src/ext/openssl/openssl.c:898:15: note: expected âASN1_UTCTIME * {aka struct
asn1_string_st *}â but argument is of type âintâ
static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr) /* {{{ */
^~~~~~~~~~~~~~~~~~~
In file included from /work/php-src/main/php.h:39:0,
from /work/php-src/ext/openssl/openssl.c:30:
/work/php-src/ext/openssl/openssl.c:2344:71: warning: passing argument 1 of
âasn1_time_to_time_tâ makes pointer from integer without a cast [-Wint-conversion]
add_assoc_long(return_value, "validTo_time_t",
asn1_time_to_time_t(X509_get_notAfter(cert)));
^
/work/php-src/Zend/zend_API.h:413:90: note: in definition of macro âadd_assoc_longâ
define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
^~~
/work/php-src/ext/openssl/openssl.c:898:15: note: expected âASN1_UTCTIME * {aka struct
asn1_string_st *}â but argument is of type âintâ
static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr) /* {{{ */
^~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c: In function âzif_openssl_csr_signâ:
/work/php-src/ext/openssl/openssl.c:3421:18: warning: passing argument 1 of
âX509_gmtime_adjâ makes pointer from integer without a cast [-Wint-conversion]
X509_gmtime_adj(X509_get_notBefore(new_cert), 0);
^~~~~~~~~~~~~~~~~~
In file included from /work/php-src/ext/openssl/openssl.c:50:0:
/usr/local/openssl11/include/openssl/x509.h:479:12: note: expected âASN1_TIME * {aka struct
asn1_string_st *}â but argument is of type âintâ
ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);
^~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c:3422:18: warning: passing argument 1 of
âX509_gmtime_adjâ makes pointer from integer without a cast [-Wint-conversion]
X509_gmtime_adj(X509_get_notAfter(new_cert), 60*60*24*(long)num_days);
^~~~~~~~~~~~~~~~~
In file included from /work/php-src/ext/openssl/openssl.c:50:0:
/usr/local/openssl11/include/openssl/x509.h:479:12: note: expected âASN1_TIME * {aka struct
asn1_string_st *}â but argument is of type âintâ
ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);
^~~~~~~~~~~~~~~
/work/php-src/ext/openssl/openssl.c: In function âzif_openssl_sealâ:
/work/php-src/ext/openssl/openssl.c:5886:2: warning: implicit declaration of function
âEVP_CIPHER_CTX_cleanupâ [-Wimplicit-function-declaration]
EVP_CIPHER_CTX_cleanup(ctx);
^~~~~~~~~~~~~~~~~~~~~~
/bin/sh /work/php-src/libtool --silent --preserve-dup-deps --mode=compile /usr/bin/gcc-6
-Iext/openssl/ -I/work/php-src/ext/openssl/ -DPHP_ATOM_INC -I/work/php-src/include
-I/work/php-src/main -I/work/php-src -I/work/php-src/ext/date/lib -I/usr/local/openssl11/include
-I/work/php-src/TSRM -I/work/php-src/Zend -O3 -Wall -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native
-fPIC -DPIC -D_GNU_SOURCE -fno-strict-aliasing -fvisibility=hidden -DZEND_SIGNALS -c
/work/php-src/ext/openssl/xp_ssl.c -o ext/openssl/xp_ssl.lo
/work/php-src/ext/openssl/xp_ssl.c: In function âphp_select_crypto_methodâ:
/work/php-src/ext/openssl/xp_ssl.c:946:22: warning: implicit declaration of function
âTLSv1_client_methodâ [-Wimplicit-function-declaration]
return is_client ? TLSv1_client_method() : TLSv1_server_method();
^~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:946:46: warning: implicit declaration of function
âTLSv1_server_methodâ [-Wimplicit-function-declaration]
return is_client ? TLSv1_client_method() : TLSv1_server_method();
^~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:946:44: warning: return makes pointer from integer without a
cast [-Wint-conversion]
return is_client ? TLSv1_client_method() : TLSv1_server_method();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:949:22: warning: implicit declaration of function
âTLSv1_1_client_methodâ [-Wimplicit-function-declaration]
return is_client ? TLSv1_1_client_method() : TLSv1_1_server_method();
^~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:949:48: warning: implicit declaration of function
âTLSv1_1_server_methodâ [-Wimplicit-function-declaration]
return is_client ? TLSv1_1_client_method() : TLSv1_1_server_method();
^~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:949:46: warning: return makes pointer from integer without a
cast [-Wint-conversion]
return is_client ? TLSv1_1_client_method() : TLSv1_1_server_method();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:957:22: warning: implicit declaration of function
âTLSv1_2_client_methodâ [-Wimplicit-function-declaration]
return is_client ? TLSv1_2_client_method() : TLSv1_2_server_method();
^~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:957:48: warning: implicit declaration of function
âTLSv1_2_server_methodâ [-Wimplicit-function-declaration]
return is_client ? TLSv1_2_client_method() : TLSv1_2_server_method();
^~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:957:46: warning: return makes pointer from integer without a
cast [-Wint-conversion]
return is_client ? TLSv1_2_client_method() : TLSv1_2_server_method();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c: In function âphp_openssl_sockop_set_optionâ:
/work/php-src/ext/openssl/xp_ssl.c:1867:22: warning: âcert_capturedâ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (n && peer_cert && cert_captured == 0) {
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/work/php-src/ext/openssl/xp_ssl.c:1737:6: note: âcert_capturedâ was declared here
int cert_captured;
^~~~~~~~~~~~~
/bin/sh /work/php-src/libtool --silent --preserve-dup-deps --mode=link /usr/bin/gcc
...
make install
ldd /usr/local/php-dev/bin/php | egrep "ssl|crypto"
libssl.so.1.1 => /usr/local/openssl11/lib64/libssl.so.1.1 (0x00007f8f58586000)
libcrypto.so.1.1 => /usr/local/openssl11/lib64/libcrypto.so.1.1 (0x00007f8f580dc000)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74378&edit=1