MAC OS自带了OpenSSL,直接在命令行里使用OPENSSL就可以。
打开命令行工具,然后输入openssl打开openssl,接着只要三句命令就可以搞定。第一句命令生成私钥;第二句命令把RSA私钥转换成PKCS8格式,密码为空就行;第三句命令生成公钥。
Last login: Fri Sep 12 00:59:51 on ttys000
stormerdeiMac:~ stormer$ openssl
OpenSSL> genrsa -outrsa_private_key.pem 1024
Generating RSA private key, 1024 bit long modulus
....++++++
..................++++++
e is 65537 (0x10001)
OpenSSL> pkcs8 -topk8 -inform PEM -inrsa_private_key.pem -outform PEM –nocrypt
Enter Encryption Password:
Verifying - Enter Encryption Password:
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIICoTAbBgkqhkiG9w0BBQMw
sTUoYmJWY+SBkv4NdwKFgkqPODbbVnpyLy
BlBVvGLVwZodummJIVYRTyQo
bqaZoHhQeKy48+tqSlv1gcff4PFjaws9TUoHQ/S65FYs/Jhhso3fGYIH3jPeU73K
kmKa4Y5tJWdj5SChJPZKUR3/1hw4+KQqpVrTNwkov98gIYhrls/lFTHTM9iWKVY+
GXc2SEbnyDZwx6Wu4N6wnM5i
mtVK5QcLYlSqmLF/Z3DkI2Pd4ve//1dsyHr9gO+GK0BX1B6ihx0yf21gMRULH7P
qmQJrMtQCyUfJNtKViVub/dsXGb9bgecAX8xzP2kBlfuNn
M41P+RQdgJ4OQXVMiiIRZzmYCn+Mxz64B7f5DFU+7tMMQV2rpPBr4aWCXOllkU/Z
h7eRLfnxzoTgm29KIYTabiwQ
KV6qZpP8cHzydWqLyJBJ0s2Y
oHAq4OU1rAskukhvP7GxUkut
xlTS9WQFw2cde1FJXV/IpHR1+mU7OdIXLRQwcWwrguSSEhD4V
Q5qYvo7HtFg8SQ6pQZMQFQE0
Q/Zb1I4=
-----END ENCRYPTED PRIVATE KEY-----
OpenSSL> rsa -in rsa_private_key.pem-pubout -out rsa_public_key.pem
writing RSA key