Commit graph

2032 commits

Author SHA1 Message Date
Shivam Mathur
4a934005b4
Fix Windows test for openssl-3.5 upgrade (#19384)
* Fix Windows test for openssl-3.5 upgrade

* Update ext/openssl/tests/check_default_conf_path.phpt

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

---------

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2025-08-06 16:11:38 +05:30
Gina Peter Banyard
dad28a30f3
main: pack _php_netstream_data_t and use bool instead of int type (#19331)
Fix use sites at the same time
2025-07-31 19:56:38 +01:00
Jakub Zelenka
ce6e7a2786
Integrate OpenSSL libctx to pwhash (#19236)
This allows using OpenSSL Argon2 password hashing on ZTS.

Closes GH-19236
2025-07-29 15:06:34 +02:00
Daniel Scherzer
ff810d5e36
Arginfo: reuse zend_string objects for initializing attribute values (#19241)
Avoid initializing the same string content multiple times and make use of the
fact that the strings created to initialize attribute values are not freed by
simply making use of an existing zend_string with the same content if one is
available.
2025-07-27 17:27:22 -07:00
Jakub Zelenka
b1fce8a98c
Add digest algo param to public encrypt and private decrypt
Specifically, it is added to openssl_public_encrypt() and
openssl_private_decrypt() functions. The purpose is to specify digest
algorithm for OEAP padding. It currently defaults to SHA1 for some
OpenSSL versions which is not preferred for modern setup and causes
problems in compatibility with web crypto.

Closes GH-19223
2025-07-25 12:56:47 +02:00
DanielEScherzer
1eadf553f1
Arginfo: avoid using temporary zvals for initializing attribute values (#19141)
Instead of
* adding a zval on the stack
* initializing it
* copying the value to the attribute

Just initialize the value directly in the zend_attribute_arg
2025-07-21 13:33:51 -07:00
Niels Dossche
478a520900
Fix incorrect OpenSSL merge 2025-07-15 21:07:25 +02:00
Niels Dossche
a22eb4d3e5
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix error return check of EVP_CIPHER_CTX_ctrl()
  Fix memleak on failure in collator_get_sort_key()
2025-07-15 20:39:30 +02:00
Niels Dossche
0f731b455c
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix error return check of EVP_CIPHER_CTX_ctrl()
  Fix memleak on failure in collator_get_sort_key()
2025-07-15 20:38:22 +02:00
Niels Dossche
cd8722304c
Fix error return check of EVP_CIPHER_CTX_ctrl()
OpenSSL can return -1 on error [1, 2], and OpenBSD's docs confirm this
[3]. Change all checks to <= 0.

[1] b3161bd9a9/crypto/evp/evp_enc.c (L1530-L1531)
[2] b3161bd9a9/crypto/evp/evp_enc.c (L1611)
[3] https://man.openbsd.org/EVP_CIPHER_CTX_ctrl.3

Closes GH-18987.
2025-07-15 20:37:33 +02:00
Niels Dossche
1089896b8c
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18986: OpenSSL backend: incorrect RAND_{load,write}_file() return value check
2025-07-15 18:52:56 +02:00
Niels Dossche
f938f356cb
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18986: OpenSSL backend: incorrect RAND_{load,write}_file() return value check
2025-07-15 18:50:46 +02:00
Niels Dossche
a8086be81c
Fix GH-18986: OpenSSL backend: incorrect RAND_{load,write}_file() return value check
As noted by the LibreSSL maintainer, these functions return -1 on error.
This is further confirmed by my static analyzer that inferred the same
thing for OpenSSL.

Closes GH-19013.
2025-07-15 18:50:19 +02:00
Jakub Zelenka
81d1529a13
Merge branch 'PHP-8.4' 2025-07-15 11:29:18 +02:00
Jakub Zelenka
0d19984cda
Merge branch 'PHP-8.3' into PHP-8.4 2025-07-15 11:24:34 +02:00
Jakub Zelenka
6b2b60f683
Fix bug #80770: openssl cafile not used in SNI SSL_CTX
The issue is about not being able to connect as cafile for SNI
is not used in its SSL context. This sets it up so it is possible
to capture the client certificate which is only possible when
verify_peer is true.

Closes GH-18893
2025-07-15 11:23:10 +02:00
Jakub Zelenka
25c0874bc1
Use custom OpenSSL libctx for NCONF (#19130) 2025-07-15 09:30:15 +02:00
Daniel Scherzer
142e378618 Arginfo: add and use known strings for attribute values 2025-07-14 17:31:22 -07:00
Jakub Zelenka
d0c0a9abfd
Introduce OpenSSL INI for selecting libctx (#18768)
Closes GH-18768

Co-authored-by: Gina Peter Banyard <girgias@php.net>
2025-07-14 15:16:14 +02:00
DanielEScherzer
ddd33fd7e4
Generated arginfo headers: combine preprocessor conditional blocks (2) (#18667)
When global constants' or class constants' availability is based on some
preprocessor condition, the generated arginfo header files wrap the
declarations in the preprocessor `#if` conditional blocks, one per declaration,
even if they are in the same conditional block based on comments in the stub
file. Instead of having multiple conditional blocks one after the other with
the same condition, combine them into a single conditional block.
2025-06-22 14:35:28 -07:00
Niels Dossche
dbabbe180b
Remove dead code from openssl_spki_new() implementation (#18752)
If s is not NULL, the length can't be <= 0 because we at least append
`spkac` in the string, which is non-empty.
I noticed this condition because if it were actually possible to
execute, then it would leak memory.
2025-06-10 22:35:56 +02:00
Jakub Zelenka
688fed36ca
Merge branch 'PHP-8.4' 2025-06-05 18:05:51 +02:00
Jakub Zelenka
7a15d2a5c0
Merge branch 'PHP-8.3' into PHP-8.4 2025-06-05 18:05:24 +02:00
Jakub Zelenka
444cc78a3e
Skip OpenSSL proxy test for bug #74796 on Windows 2025-06-05 16:18:06 +02:00
Jakub Zelenka
9ae5b4e9be
Merge branch 'PHP-8.4' 2025-06-05 14:12:48 +02:00
Jakub Zelenka
086a470208
Merge branch 'PHP-8.3' into PHP-8.4 2025-06-05 14:10:57 +02:00
Jakub Zelenka
42f6c15186
Fix bug #74796: Requests through http proxy set peer name
This issue happens because http wrapper sets peer_name but then does not
remove so it stays in the context. The fix removes the peer name from
the context after enabling crypto.

In addition to bug #74796, this also fixes bug #76196.

In addition it should be a final fix for those SOAP bugs:

bug #69783
bug #52913
bug #61463
2025-06-05 14:08:28 +02:00
Jakub Zelenka
2f5ef4d2b7
Use custom OpenSSL libctx in md and cipher handling code (#18516) 2025-06-04 18:46:00 +02:00
Niels Dossche
359bb6303d
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
2025-06-03 23:50:30 +02:00
Niels Dossche
87ff5479fc
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
2025-06-03 23:46:21 +02:00
Niels Dossche
08a9579883
Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
Closes GH-18750.
2025-06-03 23:45:51 +02:00
Niels Dossche
e2b47d8483
Merge branch 'PHP-8.4'
* PHP-8.4:
  Split off php_set_sock_blocking() and s.is_blocked to a separate function
  Fix missing checks against php_set_blocking() in xp_ssl.c
2025-05-20 08:08:46 +02:00
Niels Dossche
1e94f3423b
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Split off php_set_sock_blocking() and s.is_blocked to a separate function
  Fix missing checks against php_set_blocking() in xp_ssl.c
2025-05-20 08:08:39 +02:00
Niels Dossche
1863014fbd
Split off php_set_sock_blocking() and s.is_blocked to a separate function
This makes it harder to forget the check and keeps the variable and
function call consistent.

Closes GH-18604.
2025-05-20 08:08:06 +02:00
Niels Dossche
31ebb42268
Fix missing checks against php_set_blocking() in xp_ssl.c 2025-05-20 08:07:34 +02:00
Jakub Zelenka
cb4bafa4c0
Init OpenSSL libctx and use it for pkey (#18282) 2025-05-06 20:14:55 +02:00
Niels Dossche
8c685faa64
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix potential leaks when writing to BIO fails
2025-04-11 21:04:24 +02:00
Niels Dossche
8a927c284d
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix potential leaks when writing to BIO fails
2025-04-11 21:02:59 +02:00
Niels Dossche
29f96fb1f1
Fix potential leaks when writing to BIO fails
When the BIO is created but writing fails, these can leak.

Closes GH-18186.
2025-04-11 21:02:37 +02:00
Jakub Zelenka
2194ad81f4
Make further OpenSSL 1.0.2 clean up
Closes GH-18133
2025-04-08 18:06:56 +02:00
Niels Dossche
5a19e25347
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix inverted call to php_openssl_store_errors()
  Fix openssl_random_pseudo_bytes() always setting strong_result to true
2025-04-02 20:30:44 +02:00
Niels Dossche
a6e76ac010
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix inverted call to php_openssl_store_errors()
  Fix openssl_random_pseudo_bytes() always setting strong_result to true
2025-04-02 20:25:32 +02:00
Niels Dossche
5e68671f88
Fix inverted call to php_openssl_store_errors()
This calls php_openssl_store_errors() in the success path right now,
change it to call php_openssl_store_errors() in the error path.
2025-04-02 20:25:21 +02:00
Niels Dossche
0dc600c69a
Fix openssl_random_pseudo_bytes() always setting strong_result to true
This regressed in 62c7432f, prior to that commit the value was set to
false in case random number generation failed, but now even if an
exception is thrown it is set to true. This likely does not _really_
matter as the user will handle the exception, still the value in
$strong_result is observable.
2025-04-02 20:25:21 +02:00
Niels Dossche
a39725b793
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in openssl_sign() when passing invalid algorithm
2025-04-02 20:24:13 +02:00
Niels Dossche
d689ff63e8
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in openssl_sign() when passing invalid algorithm
2025-04-02 20:18:57 +02:00
Niels Dossche
74720a22f3
Fix memory leak in openssl_sign() when passing invalid algorithm
Closes GH-18185.
2025-04-02 20:15:53 +02:00
Jakub Zelenka
0d10f7bfe5
Remove OpenSSL 1.0.2 related code (#18032)
This also removes old LibreSSL checks as minimum that compiles is 3.5.0
2025-03-13 10:59:26 +01:00
Jakub Zelenka
2e7b6dac31
Merge branch 'PHP-8.4' 2025-02-28 14:52:37 +01:00
Jakub Zelenka
4936c32772
Merge branch 'PHP-8.3' into PHP-8.4 2025-02-28 14:51:52 +01:00