mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(keys): generate 4096-bit RSA keys
GitHub rejects new RSA SSH keys smaller than 3072 bits, and phpseclib made 2048-bit keys by default, so new RSA deploy keys from Coolify could not authenticate. Closes #12461 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
51a7e97619
commit
4bdf03db69
@@ -743,10 +743,13 @@ function generate_random_name(?string $cuid = null): string
|
||||
|
||||
return Str::kebab("{$generator->getName()}-$cuid");
|
||||
}
|
||||
/**
|
||||
* RSA keys get 4096 bits: GitHub rejects new RSA SSH keys smaller than 3072 bits, and phpseclib makes 2048-bit keys by default.
|
||||
*/
|
||||
function generateSSHKey(string $type = 'rsa')
|
||||
{
|
||||
if ($type === 'rsa') {
|
||||
$key = RSA::createKey();
|
||||
$key = RSA::createKey(4096);
|
||||
|
||||
return [
|
||||
'private' => $key->toString('PKCS1'),
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
use phpseclib3\Crypt\RSA;
|
||||
|
||||
it('generates RSA keys that GitHub accepts (at least 3072 bits)', function () {
|
||||
$keyPair = generateSSHKey('rsa');
|
||||
|
||||
$privateKey = PublicKeyLoader::load($keyPair['private']);
|
||||
$publicKey = PublicKeyLoader::load($keyPair['public']);
|
||||
|
||||
expect($privateKey)->toBeInstanceOf(RSA\PrivateKey::class)
|
||||
->and($privateKey->getLength())->toBeGreaterThanOrEqual(3072)
|
||||
->and($publicKey->getLength())->toBe($privateKey->getLength());
|
||||
});
|
||||
Reference in New Issue
Block a user