Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"illuminate/encryption": "^8.2",
"illuminate/http": "^8.2",
"illuminate/support": "^8.2",
"league/oauth2-server": "^8.2",
"lcobucci/jwt": "^3.4|^4.0",
"league/oauth2-server": "^8.2",
"nyholm/psr7": "^1.3",
"phpseclib/phpseclib": "^3.0",
"phpseclib/phpseclib": "^2.0|^3.0",
"symfony/psr-http-message-bridge": "^2.0"
},
"require-dev": {
Expand Down
15 changes: 12 additions & 3 deletions src/Console/KeysCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Laravel\Passport\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use Laravel\Passport\Passport;
use phpseclib\Crypt\RSA as LegacyRSA;
use phpseclib3\Crypt\RSA;

class KeysCommand extends Command
Expand Down Expand Up @@ -39,10 +41,17 @@ public function handle()
if ((file_exists($publicKey) || file_exists($privateKey)) && ! $this->option('force')) {
$this->error('Encryption keys already exist. Use the --force option to overwrite them.');
} else {
$key = RSA::createKey($this->input ? (int) $this->option('length') : 4096);
if (class_exists(LegacyRSA::class)) {
$keys = (new LegacyRSA)->createKey($this->input ? (int) $this->option('length') : 4096);

file_put_contents($publicKey, (string) $key->getPublicKey());
file_put_contents($privateKey, (string) $key);
file_put_contents($publicKey, Arr::get($keys, 'publickey'));
file_put_contents($privateKey, Arr::get($keys, 'privatekey'));
} else {
$key = RSA::createKey($this->input ? (int) $this->option('length') : 4096);

file_put_contents($publicKey, (string) $key->getPublicKey());
file_put_contents($privateKey, (string) $key);
}

$this->info('Encryption keys generated successfully.');
}
Expand Down