Table of contents

Linux make php 5 error: dereferencing pointer to incomplete type ‘X509_EXTENSION’

PHP Jul 05, 2020 Viewed 2.1K Comments 0

Issue

When compiling PHP 5 version in Linux, enable openssl extension. Run the following commands.

$ ./configure --prefix=/opt/php-5.6.40 --with-openssl
$ make

Finally terminated due to some errors.

/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:1904:15: error: dereferencing pointer to incomplete type ‘X509_EXTENSION’ {aka ‘struct X509_extension_st’}
 1904 |  p = extension->value->data;
      |               ^~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:1982:10: error: dereferencing pointer to incomplete type ‘X509’ {aka ‘struct x509_st’}
 1982 |  if (cert->name) {
      |          ^~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:3485:14: error: dereferencing pointer to incomplete type ‘EVP_PKEY’ {aka ‘struct evp_pkey_st’}
 3485 |  switch (pkey->type) {
      |              ^~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘php_openssl_pkey_init_dsa’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:3557:10: error: dereferencing pointer to incomplete type ‘DSA’ {aka ‘struct dsa_st’}
 3557 |  if (!dsa->p || !dsa->q || !dsa->g) {
      |          ^~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘php_openssl_pkey_init_dh’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:3580:9: error: dereferencing pointer to incomplete type ‘DH’ {aka ‘struct dh_st’}
 3580 |  if (!dh->p || !dh->g) {
      |         ^~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_pkey_new’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:3548:9: error: dereferencing pointer to incomplete type ‘RSA’ {aka ‘struct rsa_st’}
 3548 |    _type->_name = BN_bin2bn(         \
      |         ^~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:4801:13: error: storage size of ‘md_ctx’ isn’t known
 4801 |  EVP_MD_CTX md_ctx;
      |             ^~~~~~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_verify’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:4859:17: error: storage size of ‘md_ctx’ isn’t known
 4859 |  EVP_MD_CTX     md_ctx;
      |                 ^~~~~~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_seal’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:4920:17: error: storage size of ‘ctx’ isn’t known
 4920 |  EVP_CIPHER_CTX ctx;
      |                 ^~~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_open’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:5048:17: error: storage size of ‘ctx’ isn’t known
 5048 |  EVP_CIPHER_CTX ctx;
      |                 ^~~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_digest’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:5154:13: error: storage size of ‘md_ctx’ isn’t known
 5154 |  EVP_MD_CTX md_ctx;
      |             ^~~~~~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_encrypt’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:5233:17: error: storage size of ‘cipher_ctx’ isn’t known
 5233 |  EVP_CIPHER_CTX cipher_ctx;
      |                 ^~~~~~~~~~
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c: In function ‘zif_openssl_decrypt’:
/home/cpm/Downloads/packages/php-5.6.40/ext/openssl/openssl.c:5316:17: error: storage size of ‘cipher_ctx’ isn’t known
 5316 |  EVP_CIPHER_CTX cipher_ctx;
      |                 ^~~~~~~~~~
make: *** [Makefile:521: ext/openssl/openssl.lo] Error 1

Solution

PHP 5 cannot be compiled with the latest version of openssl. So we can use the older version.

$ curl -O https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
$ tar xf openssl-1.0.2u.tar.gz
$ cd openssl-1.0.2u
$ ./config --prefix=/opt/openssl-1.0.2u
$ make
$ sudo make install

Change the path of -with-openssl, make PHP again.

$ ./configure --prefix=/opt/php-5.6.40 --with-openssl=/opt/openssl-1.0.2u
$ make
$ make install
Updated Jul 05, 2020