Skip to content
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

Call to undefined function sodium_bin2base64 #665

Closed
neguradionisie opened this issue Feb 11, 2021 · 7 comments
Closed

Call to undefined function sodium_bin2base64 #665

neguradionisie opened this issue Feb 11, 2021 · 7 comments
Assignees
Labels
Milestone

Comments

@neguradionisie
Copy link

After last update 4.1.0 i got error Call to undefined function sodium_bin2base64() {"exception":"[object] (Error(code: 0): Call to undefined function sodium_bin2base64() at vendor/lcobucci/jwt/src/Encoding/JoseEncoder.php:50) my php version is 7.4.13 and sodium version 1.0.13. If i change sodium version to 1.0.18 everything is fine.

@Slamdunk
Copy link
Collaborator

sodium_bin2base64 was in fact first introduced in 1.0.14: jedisct1/libsodium@3f272cb
And first introduced in libsodium-php in 2.0.6: jedisct1/libsodium-php@0e4c821

I'll see if we can require a minimum version for ext-sodium

@Slamdunk Slamdunk self-assigned this Feb 12, 2021
@Slamdunk
Copy link
Collaborator

As I feared, even though ext-sodium version is known to PHP:

$ php -i | grep sodium
sodium
sodium support => enabled
libsodium headers version => 1.0.18
libsodium library version => 1.0.18

$ php -r 'print_r(get_defined_constants(true));' | grep -i sodium | grep -i version
            [SODIUM_LIBRARY_VERSION] => 1.0.18
            [SODIUM_LIBRARY_MAJOR_VERSION] => 10
            [SODIUM_LIBRARY_MINOR_VERSION] => 3

There is no standardization around extension versioning, so composer is unaware of it.
As a result, unfortunately we cannot require the correct version into composer.json.

We could leverage SODIUM_LIBRARY_VERSION constant, but I don't like dynamic checks for extensions.
It's worth a doc update though.

WDYT @lcobucci ?

@SvenRtbg
Copy link
Collaborator

SvenRtbg commented Feb 12, 2021 via email

@lcobucci
Copy link
Owner

I'd add back the old implementation as a new class (legacy encoder?) and put the logic to pick the new or the legacy (or the user provided one) on the config class.

Then we keep the weird stuff in the service locator.

@Slamdunk how does that sound?

@susheelk985
Copy link

Error: Call to undefined function sodium_bin2base64() in file vendor/lcobucci/jwt/src/Encoding/JoseEncoder.php on line 50

How to solve this issue?

@Slamdunk
Copy link
Collaborator

Either upgrade libsodium or wait for #670 fix to be released

@lcobucci lcobucci added the Bug label Feb 16, 2021
@lcobucci lcobucci added this to the 4.1.1 milestone Feb 16, 2021
@lcobucci
Copy link
Owner

Released!

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

No branches or pull requests

5 participants