默认是rsa_private_key1024.pem , PEM格式私钥,C# ,PHP 用。
再生成 pkcs8 格式私钥, JAVA 用。
公钥无格式区分。
1024 的:
openssl.exe genrsa -out rsa_private_key1024.pem 1024
openssl.exe pkcs8 -topk8 -inform PEM -in rsa_private_key1024.pem -outform pem -nocrypt -out rsa_private_key1024_pkcs8.pem
openssl.exe rsa -in rsa_private_key1024.pem -pubout -out rsa_public_key1024.pem
pause
2048的:
openssl.exe genrsa -out rsa_private_key2048.pem 2048
openssl.exe pkcs8 -topk8 -inform PEM -in rsa_private_key2048.pem -outform pem -nocrypt -out rsa_private_key2048_pkcs8.pem
openssl.exe rsa -in rsa_private_key2048.pem -pubout -out rsa_public_key2048.pem
pause
以上生成的文件和openssl.exe同目录。可以指定目录来生成。
生成的批处理:
echo "路径不能有中文"
set tooldir=C:\OpenSSL-Win64\bin
set keydir=D:\opensslgenkey
%tooldir%\openssl.exe genrsa -out %keydir%\rsa_private_key2048.pem 2048
%tooldir%\openssl.exe pkcs8 -topk8 -inform PEM -in %keydir%\rsa_private_key2048.pem -outform pem -nocrypt -out %keydir%\rsa_private_key2048_pkcs8.pem
%tooldir%\openssl.exe rsa -in %keydir%\rsa_private_key2048.pem -pubout -out %keydir%\rsa_public_key2048.pem
pause