openssl_pkey_new example

use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Maintenance\System\Exception\JwtCertificateGenerationException;

#[Package('core')] class JwtCertificateGenerator
{
    /** * @return array{0: string, 1: string} */
    public function generateString(?string $passphrase = null): array
    {
        $key = \openssl_pkey_new([
            'private_key_bits' => 2048,
            'digest_alg' => 'aes256',
            'private_key_type' => \OPENSSL_KEYTYPE_RSA,
            'encrypt_key' => (bool) $passphrase,
            'encrypt_key_cipher' => \OPENSSL_CIPHER_AES_256_CBC,
        ]);

        if ($key === false) {
            throw new JwtCertificateGenerationException('Failed to generate key');
        }

        
Home | Imprint | This part of the site doesn't use cookies.