Commit graph

1926 commits

Author SHA1 Message Date
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
444cc78a3e
Skip OpenSSL proxy test for bug #74796 on Windows 2025-06-05 16:18:06 +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
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
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
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
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
74720a22f3
Fix memory leak in openssl_sign() when passing invalid algorithm
Closes GH-18185.
2025-04-02 20:15:53 +02:00
Jakub Zelenka
6bb56fe0cf
Change openssl_x509_verify test to use cert generator (#17882)
This also prevents verifying cert with SHA1 signature
2025-02-28 14:51:12 +01:00
Jakub Zelenka
e0dabe326f
Merge branch 'PHP-8.2' into PHP-8.3 2024-12-31 15:05:18 +01:00
Jakub Zelenka
37504f123d
Port OpenSSL gh10495, gh13860 and gh9310 test to use ephemeral ports 2024-12-31 15:02:08 +01:00
Jakub Zelenka
44a9154e75
Merge branch 'PHP-8.1' into PHP-8.2 2024-12-31 14:39:59 +01:00
Jakub Zelenka
b8731767d8
Fix GH-16955: Use empheral ports for OpenSSL server client tests
And refactor some client server tests.

Closes GH-17180
2024-12-31 14:25:19 +01:00
Niels Dossche
80dd5a0306
Fix wrong merge 2024-11-09 11:49:08 +01:00
Niels Dossche
591fe92724
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix memory leak in php_openssl_pkey_from_zval()
  Fix various memory leaks related to openssl exports
  Prevent unexpected array entry conversion when reading key
2024-11-09 11:01:21 +01:00
Niels Dossche
994e866cf2
Fix memory leak in php_openssl_pkey_from_zval()
Closes GH-16691.
2024-11-09 10:58:44 +01:00
Niels Dossche
2f4f09f7e6
Fix various memory leaks related to openssl exports
Closes GH-16692.
2024-11-09 10:58:17 +01:00
Niels Dossche
ac8d0e57d9
Prevent unexpected array entry conversion when reading key
When passing an array, the key entry can get converted to a string if it
is an object, but this actually modifies the original array entry.
The test originally outputted:

```
array(2) {
  [0]=>
  string(...) => ...
  [1]=>
  string(0) ""
}
```

This is unexpected. Use zval_try_get_string() to prevent this behaviour.

Closes GH-16693.
2024-11-09 10:57:50 +01:00
Niels Dossche
673e8d1011
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix various memory leaks on error conditions in openssl_x509_parse()
2024-11-04 20:04:18 +01:00
Niels Dossche
5ddb75660d
Fix various memory leaks on error conditions in openssl_x509_parse()
Closes GH-16690.
2024-11-04 20:03:53 +01:00
Christoph M. Becker
931762c626
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16433: Large values for openssl_csr_sign() $days overflow
2024-10-16 11:09:00 +02:00
Christoph M. Becker
2bdf2f9100
Fix GH-16433: Large values for openssl_csr_sign() $days overflow
The `offset_sec` parameter of `X509_gmtime_adj()` expects a `long`, but
the `$days` parameter of `openssl_csr_sign()` a `zend_long`.  We must
avoid signed integer overflow (UB), but also must not silently truncate.
Thus we check the given `$days` for the permissible range, and bail out
otherwise.

Closes GH-16437.
2024-10-16 11:08:02 +02:00
Christoph M. Becker
76a819e7d1
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16357: openssl may modify member types of certificate arrays
2024-10-12 16:06:44 +02:00
Christoph M. Becker
549bcdb7fb
Fix GH-16357: openssl may modify member types of certificate arrays
We must not use `try_convert_to_string()` on members of unseparated
array arguments; instead of separating, we use `zval_try_get_string()`.

Closes GH-16370.
2024-10-12 16:05:31 +02:00
Jakub Zelenka
53cc92c85c
Fix failing openssl_private_decrypt tests
We backport 11caf094f1af6b47ea2138c5fa907838911ebe01[1] as a step to
get back to a green CI.

[1] <11caf094f1>
2024-10-07 01:06:04 +02:00
Jakub Zelenka
37a73a83c3
Merge branch 'PHP-8.2' into PHP-8.3 2024-09-28 16:24:01 +01:00
Jakub Zelenka
dce0d97640
Fix stub for openssl_csr_new 2024-09-28 16:22:08 +01:00
Arnaud Le Blanc
6b54d3b26f
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix test race condition
2024-07-03 19:17:43 +02:00
Arnaud Le Blanc
070779c874
Fix test race condition
Closes GH-14790
2024-07-03 19:17:13 +02:00
Jakub Zelenka
82e6040cff
Merge branch 'PHP-8.2' into PHP-8.3 2024-06-09 12:40:51 +01:00
Jakub Zelenka
46013f1c55
Skip test for OpenSSL bug #74341 which is not a bug 2024-06-09 12:40:24 +01:00
Ilija Tovilo
614323e4b6
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Fix typo
2024-05-13 13:08:49 +02:00
Ilija Tovilo
fa7933ef17
[skip ci] Fix typo 2024-05-13 13:08:28 +02:00
Ilija Tovilo
018ee8dc6e
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Adjust port for gh13860.phpt
2024-05-13 12:17:05 +02:00
Ilija Tovilo
91c53e43c4
[skip ci] Adjust port for gh13860.phpt
Port 64325 is already used in ext/standard/tests/streams/gh11418.phpt. The test
randomly times out, and it's unclear whether it might be related to the
conflicting port.
2024-05-13 12:16:57 +02:00
Jakub Zelenka
353571e29b
Merge branch 'PHP-8.2' into PHP-8.3 2024-04-19 14:09:53 +01:00
Jakub Zelenka
04b864e566
Fix GH-13806: openssl_x509_parse_basic test fails with OpenSSL 3.2+ (#13961)
Closes GH-13961
2024-04-19 14:09:22 +01:00
Niels Dossche
73218e063a
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Improve stability of test gh13860.phpt
2024-04-07 22:50:09 +02:00
Niels Dossche
a86256c950
Improve stability of test gh13860.phpt 2024-04-07 22:49:58 +02:00
Niels Dossche
92136640aa
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13860: Incorrect PHP_STREAM_OPTION_CHECK_LIVENESS case in ext/openssl/xp_ssl.c - causing use of dead socket
2024-04-07 21:37:01 +02:00
Niels Dossche
2aae14c8a9
Fix GH-13860: Incorrect PHP_STREAM_OPTION_CHECK_LIVENESS case in ext/openssl/xp_ssl.c - causing use of dead socket
php_socket_errno() may return a stale value when recv returns a
value >= 0. As such, the liveness check is wrong.
This is the same bug as #70198 (fixed in GH-1456). So we fix it in the
same way.

Closes GH-13895.
2024-04-07 21:35:43 +02:00
Jakub Zelenka
b7992d4eb7 Fix OpenSSL error string tests 2024-03-30 18:36:34 +00:00
Jakub Zelenka
9cf0f30193
Merge branch 'PHP-8.2' into PHP-8.3 2024-03-29 19:39:15 +00:00
Jakub Zelenka
11caf094f1
Fix GH-13620: Failing openssl_private_decrypt tests
Use OPENSSL_PKCS1_OAEP_PADDING padding in tests

Closes GH-13667
2024-03-29 19:33:37 +00:00
Jakub Zelenka
5231e71bfd
Merge branch 'PHP-8.2' into PHP-8.3 2024-03-29 16:33:26 +00:00
Jakub Zelenka
100258ffd6
Fix test for GH-10495: feof on OpenSSL stream hangs 2024-03-29 16:32:23 +00:00
Jakub Zelenka
f4a9ae90f9
Merge branch 'PHP-8.2' into PHP-8.3 2024-03-29 16:25:09 +00:00
Jakub Zelenka
c1bd9a932a
Fix GH-10495: feof on OpenSSL stream hangs indefinitely
This fixes the issue with unbounded waiting on SSL_peek which can happen
when only part of the record is fetched. It makes socket non blocking so
it is possible to verify if OpenSSL is expecting some more data or if
there is an error.

This also fixes bug #79501

Closes GH-13487
2024-03-29 16:22:22 +00:00