Export private key in PKCS#8 format using openssl bindings?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux