openssl generates public and private keys in RSA format and converts them to pkcs8 format

Step 1: Generate a private key, here we specify the length of the private key as 2048

openssl genrsa -out rsa_private_key.pem 2048

Step 2: Generate the corresponding public key according to the private key:

openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key_2048.pub

Step 3: Convert the private key to pkcs8 format, [this step is not necessary, but the program is easy to parse], the angle brackets mean: write the converted private key into the rsa_private_key_pkcs8.pem file

openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt > rsa_private_key_pkcs8.pem

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324934798&siteId=291194637