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

Could not get class storage for opensslcertificate #7100

Closed
dvaeversted opened this issue Dec 8, 2021 · 6 comments · Fixed by #8677
Closed

Could not get class storage for opensslcertificate #7100

dvaeversted opened this issue Dec 8, 2021 · 6 comments · Fixed by #8677
Assignees

Comments

@dvaeversted
Copy link

Ran into this issue, when changing from running psalm on PHP 7.4 to PHP 8.0

After a lot of trial and error, i was able to create a simple reproducer that shows on the psalm.dev interface aswell.

https://psalm.dev/r/f8a923cc47

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/f8a923cc47
<?php

$result = openssl_x509_verify('a', 'b');
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php: Could not get class storage for opensslcertificate

@weirdan
Copy link
Collaborator

weirdan commented Dec 8, 2021

It's interesting that we still have this issue even when Psalm is targeting 7.1: https://psalm.dev/r/f8a923cc47?php=7.1

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/f8a923cc47
<?php

$result = openssl_x509_verify('a', 'b');
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php: Could not get class storage for opensslcertificate

@weirdan weirdan added the bug label Dec 8, 2021
@weirdan weirdan self-assigned this Dec 8, 2021
@dvaeversted
Copy link
Author

I believe it is entirely dependent on the actual PHP version that is being used to run it, and not the language level at all.

If i run the above test script through psalm, while using PHP 7.4 i do not get the internal error.
However running it on 8.0 or 8.1, the internal error happens.

Perhaps it is related to the introduction of the OpenSSLCertificate class introduced in PHP 8.0 ?

I noticed that another function, that also takes the OpenSSLCertificate class as argument does not cause an internal error.
For example the openssl_x509_read() function.

Which led my to try this out: https://psalm.dev/r/7b64ca57f3

It seems, as long as there is a prior call that loads in the OpenSSLCertificate class, everything is happy.
Instantiating the class for no reason, also stops the internal error from happening: https://psalm.dev/r/4f4e4b8e61

Lastly the openssl_x509_verify() function, is not present in the dictionaries/CallMap.php file.

Adding the following line to that file, seems to remove the crash.

'openssl_x509_verify' => ['int', 'certificate'=>'string|resource', 'public_key'=>'string|resource'],

But i honestly have limited idea whether that is the right thing to do ?

Not sure if any of this is of any help,

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/7b64ca57f3
<?php

$a = openssl_x509_read('a');

$b = openssl_x509_verify('a', 'b');
Psalm output (using commit fb07d58):

INFO: UnusedVariable - 3:1 - $a is never referenced or the value is not used

INFO: UnusedVariable - 5:1 - $b is never referenced or the value is not used
https://psalm.dev/r/4f4e4b8e61
<?php

new OpenSSLCertificate();

$b = openssl_x509_verify('a', 'b');
Psalm output (using commit fb07d58):

INFO: UnusedVariable - 5:1 - $b is never referenced or the value is not used

@orklah
Copy link
Collaborator

orklah commented Nov 6, 2022

This should be fixed in latest release. Sorry it took so long, this was a pretty simple change that you even suggested... I just missed it completely

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

Successfully merging a pull request may close this issue.

3 participants