Export private key in PKCS#8 format using openssl bindings?
| From: | Jonas Meurer | Date: | Wed, 06 Feb 2019 17:01:20 +0000 |
| Subject: | Export private key in PKCS#8 format using openssl bindings? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-326702@lists.php.net to get a copy of this message | ||
Hello,
I wonder, what's the best way to export a private key from a keypair
generated with
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
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
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc