标签:
MAC OS自带了OpenSSL,所以不用去编译那一坨跟SHIT一样的源码。直接在命令行里使用OPENSSL就可以。
打开命令行工具,然后输入 openssl打开openssl,接着只要三句命令就可以搞定。第一句命令生成私钥;第二句命令把RSA私钥转换成PKCS8格式,密码为空就行;第三句命令生成公钥。
Last login: Fri Sep 12 00:59:51 on ttys000
stormerdeiMac:~ stormer$ openssl
OpenSSL> genrsa -out rsa_private_key.pem 1024
Generating RSA private key, 1024 bit long modulus
....++++++
..................++++++
e is 65537 (0x10001)
OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM –nocrypt
Enter Encryption Password:
Verifying - Enter Encryption Password:
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIICoTAbBgkqhkiG9w0BBQMwDgQIStQxV5Ap0rECAggABIICgCN+n27Qujr/tQ5B
sTUoYmJWY+SBkv4NdwKFgkqPODbbVnpyLyDXO5BDgyjql6mdrOnGmYL1GYoNWHiy
BlBVvGLVwZodummJIVYRTyQoeazUSsdv0ahxf1mpSvhJzHpycUwPo9BY+uLCFISq
bqaZoHhQeKy48+tqSlv1gcff4PFjaws9TUoHQ/S65FYs/Jhhso3fGYIH3jPeU73K
kmKa4Y5tJWdj5SChJPZKUR3/1hw4+KQqpVrTNwkov98gIYhrls/lFTHTM9iWKVY+
GXc2SEbnyDZwx6Wu4N6wnM5iXKNh+wPMM2Fwsml9Pcqh2Z2spG0yaKARhCiVKPTn
mtVK5QcLYlSqmLF/Z3DkI2Pd4ve//1dsyHr9gO+GK0BX1B6ihx0yf21gMRULH7PS
qmQJrMtQCyUfJNtKViVub/dsXGb9bgecAX8xzP2kBlfuNnle45gCTAlqQ53OkCM6
M41P+RQdgJ4OQXVMiiIRZzmYCn+Mxz64B7f5DFU+7tMMQV2rpPBr4aWCXOllkU/Z
h7eRLfnxzoTgm29KIYTabiwQMxa03o9pzJeI9yFvmdwwA40wGknh5PJTFsUJw57r
KV6qZpP8cHzydWqLyJBJ0s2YOALuZI8nd2y3lGK3eyWqDERcD0ChH1sraV2jccB+
oHAq4OU1rAskukhvP7GxUkut7yZGZ9b57L0ILP+764OZOqMlmwsTbO3oKaHi7YeV
xlTS9WQFw2cde1FJXV/IpHR1+mU7OdIXLRQwcWwrguSSEhD4V6YKN5mO69XPuTzD
Q5qYvo7HtFg8SQ6pQZMQFQE0xS7tHf9DjP+XjXUUwJx8C9DPZlMB02bH47cMG6Jf
Q/Zb1I4=
-----END ENCRYPTED PRIVATE KEY-----
OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
writing RSA key
最后附上截图。
就这些,很简单。
标签:
原文地址:http://www.cnblogs.com/sytfyf/p/4463177.html