[php-src] Issue #21762: FTBFS against OpenSSL 4.0.0

[email protected] (fazalmajid)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21762
Author: fazalmajid

### Description

OpenSSL 4.0.0 removed a number of deprecated APIs and made ASN1_STRING an opaque type. This causes PHP to fail to build from source, see ftbfs.txt for the output/

FWIW, here is a patch generated by Claude that fixes:
                                                                                
  1. php_openssl.h — adds #ifndef ERR_NUM_ERRORS / #define ERR_NUM_ERRORS 16 /  
  #endif after #include <openssl/err.h>. This constant was removed from OpenSSL 
  4.0's err.h and is used in the struct definition plus 3 places in openssl.c.  
  2. openssl_backend_common.c — replaces three direct ->data/->length member
  accesses on ASN1_STRING (now an opaque typedef) with the public accessors     
  ASN1_STRING_get0_data() and ASN1_STRING_length().
  3. xp_ssl.c — same treatment for the GEN_IPADD block: introduces              
  ip_data/ip_len locals via the accessors, used in the IPv4 snprintf, IPv6      
  length check, and EXPAND_IPV6_ADDRESS macro.

It is failing several TLS-related test, not sure how much of this is removed APIs:

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
CURLOPT_SSL* basic client auth tests [ext/curl/tests/curl_setopt_ssl.phpt]
Bug #53251 (bindtextdomain with null dir doesn't return old value) [ext/gettext/tests/bug53251.phpt]
#66265: gettext doesn't switch locales within the same script [ext/gettext/tests/bug66267.phpt]
Gettext basic test with en_US locale that should be on nearly every system [ext/gettext/tests/gettext_basic-enus.phpt]
Gettext basic test [ext/gettext/tests/gettext_basic.phpt]
Test if bindtextdomain() returns string id if no directory path is set(if directory path is 'null') [ext/gettext/tests/gettext_bindtextdomain-cwd.phpt]
Test dcgettext() functionality [ext/gettext/tests/gettext_dcgettext.phpt]
Test dgettext() functionality [ext/gettext/tests/gettext_dgettext.phpt]
Test if dngettext() returns the correct translations (optionally plural). [ext/gettext/tests/gettext_dngettext-plural.phpt]
Test ngettext() functionality [ext/gettext/tests/gettext_ngettext.phpt]
Check if textdomain() returns the new domain [ext/gettext/tests/gettext_textdomain-retval.phpt]
Bug #28382 (openssl_x509_parse extensions support) [ext/openssl/tests/bug28382.phpt]
Bug #74796: TLS encryption fails behind HTTP proxy [ext/openssl/tests/bug74796.phpt]
openssl_*() with OPENSSL_KEYTYPE_EC for ec custom params [ext/openssl/tests/ecc_custom_params.phpt]
openssl_x509_parse() tests [ext/openssl/tests/openssl_x509_parse_basic_openssl32.phpt]
sni_server [ext/openssl/tests/sni_server.phpt]
sni_server with separate pk and cert [ext/openssl/tests/sni_server_key_cert.phpt]
tls stream wrapper with min version 1.0 and max version 1.1 [ext/openssl/tests/tls_min_v1.0_max_v1.1_wrapper.phpt]
tls stream wrapper [ext/openssl/tests/tls_wrapper.phpt]
tls stream wrapper when TLS 1.3 available [ext/openssl/tests/tls_wrapper_with_tls_v1.3.phpt]
tlsv1.0 stream wrapper [ext/openssl/tests/tlsv1.0_wrapper.phpt]
tlsv1.1 stream wrapper [ext/openssl/tests/tlsv1.1_wrapper.phpt]
tlsv1.2 stream wrapper [ext/openssl/tests/tlsv1.2_wrapper.phpt]
Killing server should terminate all worker processes [sapi/cli/tests/php_cli_server_pdeathsig.phpt]
=====================================================================

=====================================================================
WARNED TEST SUMMARY
---------------------------------------------------------------------
Test multiple watch elements pointing to the same watchpoint [sapi/phpdbg/tests/watch_006.phpt] (warn: XFAIL section but test passes)
=====================================================================


[php-openssl4.txt](https://github.com/user-attachments/files/26729998/php-openssl4.txt)

[ftbfs.txt](https://github.com/user-attachments/files/26730120/ftbfs.txt)

### PHP Version

```plain
PHP 8.5.5 (cli) (built: Apr 14 2026 22:42:02) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies
```

### Operating System

Alpine Linux 3.23.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.