Export private key in PKCS#8 format using openssl bindings?
- Date: Wed, 6 Feb 2019 18:01:20 +0100
- From: Jonas Meurer <jonas@xxxxxxxxxxxxxxx>
- Subject: Export private key in PKCS#8 format using openssl bindings?
Hello, I wonder, what's the best way to export a private key from a keypair generated with `openssl_pkey_new()` into PKCS#8 format in PHP. I use the PHP openssl bindings to generate and export a private/public keypair: > $pKey = openssl_pkey_new(); > openssl_pkey_export($pKey, $privateKey); > $publicKey = openssl_pkey_get_details($pKey)['key']; Unfortunately, for some reason, PHP openssl bindings still export the private key in traditional format, instead of using the PKCS#8 format. Since the openssl bindings don't seem to support exporting in PKCS#8 format, it seems like I have two options: 1. spawn a system process and use `openssl pkey` to transform the exported key into PKCS#8 format. 2. add phpseclib dependency and use it to import+export the generated key in PKCS#8 format. Do you have other ideas? Am I missing something? Looking forward to your responses. Cheers jonas
Description: OpenPGP digital signature
- Prev by Date: Adding php-fpm pools without having to fully stop/start php-fpm?
- Next by Date: PHP 7.3.2 Released
- Previous by thread: Adding php-fpm pools without having to fully stop/start php-fpm?
- Next by thread: PHP 7.3.2 Released