Is there a way to generate private key via OpenSSL in PHP using openssl-pkey-new in RSA and PKCS1?
Asked
Active
Viewed 3,177 times
2
-
Possible duplicate of [Can PHP OpenSSL generate private/public key/certificate pairs?](http://stackoverflow.com/questions/7414044/can-php-openssl-generate-private-public-key-certificate-pairs) – jww Mar 27 '15 at 00:31
-
No dup - I need generate RSA in PKCS1 format. – Pavel Mar 27 '15 at 07:59
-
[PKCS1 is not secure](http://stackoverflow.com/a/34088308/2224584). – Scott Arciszewski Mar 06 '16 at 18:50
1 Answers
3
if you mean private key with BEGIN RSA PRIVATE KEY header then there is one issue in PHP that does not have simple solution. Basically PHP compiled with OpenSSL 1.0+ produce PKCS#8 PEM formatted private keys and it seems like there is no way how to generate it in PKCS#1 format anymore (at least I was not able to find solution).
https://bugs.php.net/bug.php?id=53850
Why different private key strings under Linux or Windows?
There is also library called phpseclib that shoul be able to do it. (but I don't have personal experience with it).
http://phpseclib.sourceforge.net/rsa/examples.html#create,pkcs1,pkcs1pub,sign1,enc1,