exists($privateKeyPath); $publicExists = $disk->exists($publicKeyPath); if (($privateExists || $publicExists) && !$this->option('force')) { $this->error('Key pair already exists. Use --force to overwrite.'); return 1; } $keyPair = $this->generateKeyPair(); $disk->put($privateKeyPath, $keyPair['privateKey']); $disk->put($publicKeyPath, $keyPair['publicKey']); $this->info('Generated application license key pair.'); $this->line('Private key: ' . $privateKeyPath); $this->line('Public key: ' . $publicKeyPath); return 0; } protected function generateKeyPair(): array { $privateKey = openssl_pkey_new([ 'private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA, ]); openssl_pkey_export($privateKey, $privateKeyPem); $publicKeyDetails = openssl_pkey_get_details($privateKey); return [ 'privateKey' => $privateKeyPem, 'publicKey' => $publicKeyDetails['key'], ]; } }