Why different private key strings under Linux or Windows?

后端 未结 2 2021
暖寄归人
暖寄归人 2020-12-19 01:05

When I\'m creating private key strings with the following PHP code (and same config-parameter), they are enclosed between different strings:

$configs = array         


        
2条回答
  •  醉酒成梦
    2020-12-19 01:56

    This is a differece between openssl versions not PHP. The following openssl command creates different key headers/footers between openssl versions 0.9.x and 1.0.0x:

    openssl req -new -keyout mykey.key -out mycertreq.csr -nodes -sha1 -newkey rsa:2048

    For version 0.9.x, the key header/footer is:

    -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----

    For version 1.0.0x, the key header/footer is:

    -----BEGIN PRIVATE KEY----- -----END PRIVATE KEY-----

    For the later version of openssl, I have to run the key file through the following command to make it compatible with the older default:

    openssl rsa -in mykey.key -text > mykey.pem

    The "mykey.pem" file then has the header/footers (and format) that is compatible with AWS and like services.

提交回复
热议问题