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

Error Creating OpenSSL DSA Keys #720

Closed
2 of 5 tasks
Sephster opened this issue Apr 3, 2023 · 1 comment
Closed
2 of 5 tasks

Error Creating OpenSSL DSA Keys #720

Sephster opened this issue Apr 3, 2023 · 1 comment
Assignees
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow

Comments

@Sephster
Copy link

Sephster commented Apr 3, 2023

Describe the bug
I am unsure why but I can't create a DSA key using the following code:

$res = \openssl_pkey_new([
                'digest_alg' => 'sha512',
                'private_key_bits' => 2048,
                'private_key_type' => OPENSSL_KEYTYPE_DSA,
            ]);
            // Get private key
            \openssl_pkey_export($res, $keyContent, 'mystrongpassword');

This code works fine for PHP 8.1 and 8.2 but fails in 7.4 and 8.0. The call to openssl_pkey_new() returns false. I have been able to generate such a key locally on PHP 7.4 and 8.0 in other environments so suspect this might be something to do with the openssl.cnf on the runners although this is purely a guess.

Version

  • I have checked releases, and the bug exists in the latest patch version of v1 or v2.
  • v2
  • v1

Runners

  • GitHub Hosted
  • Self Hosted

Operating systems
Ubuntu-latest

PHP versions
7.4, 8.0, 8.1, 8.2

To Reproduce
I create a basic test repo to show the issue

Expected behavior
The call to openssl_pkey_new should return an OpenSSLAsymetricKey

Screenshots/Logs
Detailed in the test repo

Additional context
N/A

Are you willing to submit a PR?
I'm unsure of the root cause so wouldn't be able to at this time

@Sephster Sephster added the bug Something isn't working label Apr 3, 2023
@shivammathur
Copy link
Owner

shivammathur commented Apr 11, 2023

@Sephster

If you are running this on the ubuntu-latest or ubuntu-22.04 runner, that has OpenSSL 3 and support for it was added to PHP in 8.1. Please use ubuntu-20.04 runner with the older PHP versions and this should work.

@shivammathur shivammathur added workflow-edit Issue can be fixed by editing the GitHub Action workflow and removed bug Something isn't working labels Apr 11, 2023
chalasr added a commit to lexik/LexikJWTAuthenticationBundle that referenced this issue Dec 27, 2023
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[CI] Fixed CI for PHP 7.2

This PR is my attempt at fixing the "always green" build for 7.2 (mentioned in #1183 (comment))

Things done:
1) I've bumped the PHPUnit Bridge version to the latest one.

According to [PHPUnit Bridge doc](https://symfony.com/doc/current/components/phpunit_bridge.html#installation):
```
The PHPUnit bridge is designed to work with all maintained versions of Symfony components, even across different major versions of them. You should always use its very latest stable major version to get the most accurate deprecation report.
```

Allowing phpunit-bridge range of `"^4.4|^5.4|^6.0|^7.0"` together with `--prefer-lowest` means that the 4.4.0 version of it is installed - which doesn't have all the required bugfixes.

I've chosen ^7.0 as the latest one, for the 7.x series 7.0.1 is needed because it contains the bugfix for this issue: symfony/demo#1457 (comment)

2) Set PHPUnit 9.5 as the max version

The 7.2 build cannot use PHPUnit 9.5, [it requires PHP 7.3](https://github.com/sebastianbergmann/phpunit/blob/9.5.0/composer.json#L24)

I've set this as max version instead - it will be used if possible, otherwise lower versions will be used.

3) Bumped lowest supported version of lcobucci/jwt to 3.4.6

One of the tests was failing:
```
1) Lexik\Bundle\JWTAuthenticationBundle\Tests\Functional\GetTokenTest::testGetTokenWithCustomClaim
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 'foo'
-    1 => 'bar'
 )
```

This was fixed by bumping the version of lcobucci/jwt to 3.4.6 - I suspect it contains bugfix not present in 3.4.0

4) Run PHP 7.2 tests on ubuntu-20

I found this issue when googling: shivammathur/setup-php#720
```
If you are running this on the ubuntu-latest or ubuntu-22.04 runner, that has OpenSSL 3 and support for it was added to PHP in 8.1. Please use ubuntu-20.04 runner with the older PHP versions and this should work.
```

And it was right, all of a sudden the segmentation faults have disappeared.

Overall I feel everything I did was a bit hacky, but the build is now green 🎉

Commits
-------

29c88f2 [CI] Fixed CI for PHP 7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow
Projects
None yet
Development

No branches or pull requests

2 participants