chore(ssl): improve code in ssl helper

This commit is contained in:
peaklabs-dev
2025-01-30 14:37:12 +01:00
parent 3632f29af8
commit 546001890c

View File

@@ -7,10 +7,6 @@ use Carbon\Carbon;
class SslHelper class SslHelper
{ {
private const DEFAULT_KEY_BITS = 4096;
private const DEFAULT_DIGEST_ALG = 'sha256';
private const DEFAULT_VALIDITY_YEARS = 10; private const DEFAULT_VALIDITY_YEARS = 10;
private const DEFAULT_ORG_NAME = 'Coolify'; private const DEFAULT_ORG_NAME = 'Coolify';
@@ -27,9 +23,9 @@ class SslHelper
try { try {
$privateKey = openssl_pkey_new([ $privateKey = openssl_pkey_new([
'private_key_bits' => self::DEFAULT_KEY_BITS,
'private_key_type' => OPENSSL_KEYTYPE_RSA, 'private_key_type' => OPENSSL_KEYTYPE_RSA,
'encrypt_key' => true, 'private_key_bits' => 4096,
'encrypt_key' => false,
]); ]);
if ($privateKey === false) { if ($privateKey === false) {
@@ -46,9 +42,9 @@ class SslHelper
]; ];
$csr = openssl_csr_new($dn, $privateKey, [ $csr = openssl_csr_new($dn, $privateKey, [
'digest_alg' => self::DEFAULT_DIGEST_ALG, 'digest_alg' => 'sha512',
'config' => null, 'config' => null,
'encrypt_key' => true, 'encrypt_key' => false,
]); ]);
if ($csr === false) { if ($csr === false) {
@@ -63,7 +59,7 @@ class SslHelper
$privateKey, $privateKey,
$validityDays, $validityDays,
[ [
'digest_alg' => self::DEFAULT_DIGEST_ALG, 'digest_alg' => 'sha512',
'config' => null, 'config' => null,
], ],
random_int(PHP_INT_MIN, PHP_INT_MAX) random_int(PHP_INT_MIN, PHP_INT_MAX)