openssl_pkey_export example

'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');
        }

        if (!openssl_pkey_export($key$privateKey$passphrase)) {
            throw new JwtCertificateGenerationException('Failed to export private key');
        }

        $keyData = openssl_pkey_get_details($key);
        if ($keyData === false) {
            throw new JwtCertificateGenerationException('Failed to export public key');
        }

        return [$privateKey$keyData['key']];
    }

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