Skip to content

ArgumentCountError Thrown When Using openssl_public_encrypt and Other OpenSSL Functions #18387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alperenuzun opened this issue Apr 21, 2025 · 4 comments

Comments

@alperenuzun
Copy link

Description

After migrating from Amazon Linux 2 to Ubuntu 22.04 — and upgrading OpenSSL from version 1.0.2 to 3.0.2 — I have encountered two recurring types of errors:


1. OpenSSL Encryption Method Errors (ArgumentCountError)

When calling the openssl_public_encrypt function, it seems the method signature has changed, resulting in errors such as:

openssl_public_encrypt() expects exactly 1 argument, 4 given
openssl_public_encrypt() expects exactly 2 arguments, 4 given
openssl_public_encrypt() expects at most 3 arguments, 4 given

Other methods also show similar inconsistencies:

openssl_pkey_get_private() expects at least 2 arguments, 1 given
openssl_pkey_get_private() expects exactly 1 argument, 1 given

While this may indicate changes in method signatures or internal validation logic, it's still unclear why different ArgumentCountError messages are thrown for the same method.


2. cURL Errors

cURL error 35: error:03000072:digital envelope routines::decode error

This error occurs intermittently, particularly during peak request times.


Error Frequency: 10–20 times per day (Not always)
OpenSSL Version: 3.0.9


Questions

  • Has anyone else experienced similar issues after upgrading to OpenSSL 3.x and Ubuntu 22.04?
  • Could this be related to the PHP version or its OpenSSL extension compatibility?

Any insights or suggestions would be greatly appreciated.

Best regards,

PHP Version

PHP 8.1.31 (cli) (built: Nov 21 2024 13:10:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.31, Copyright (c) Zend Technologies
with Zend OPcache v8.1.31, Copyright (c), by Zend Technologies

Operating System

Ubuntu 22.04

@iluuu1994
Copy link
Member

Can you try upgrading to PHP 8.1.32? Is this not available in Ubuntu 22.04 yet?

@iluuu1994
Copy link
Member

@alperenuzun Could you also clarify whether you're using JIT or any 3rd party extensions?

@alperenuzun
Copy link
Author

@iluuu1994

My apologies for the mistake; my PHP version is actually 8.1.2.

Below is the JIT output:

php -i |grep JIT
PCRE JIT Support => enabled
PCRE JIT Target => ARM-64 64bit (little endian + unaligned)
JIT => On

Additionally, here are the enabled modules:

php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
mcrypt
mongodb
msgpack
mysqli
mysqlnd
OAuth
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
phalcon
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
uuid
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache

I haven't attempted to upgrade to a newer PHP version yet. This is because the error is difficult to reproduce using a local image, and upgrading PHP in our production environment also presents challenges. Therefore, I would prefer to exhaust all troubleshooting steps with the current version first.

Considering this situation, do you believe upgrading is likely to fix the issue and is it a worthwhile step to consider despite the difficulty?

@iluuu1994
Copy link
Member

8.1.2 is over 3 years old at this point. Chances are that this issue is already fixed, and thus any investigation to find the cause would be a waste of time. Hence, please upgrade first.

It would also be worth trying to disable the JIT (not PCRE JIT), as it can sometimes lead to issues (especially given how old this version is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants