openssl genrsa -out rs256_private_key.pem 2048
生成的PKCS1格式私钥示例
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAnAUSXxqv7dsrb42IdwR8yJ+sYi0YCduTXbcNOurVLu9gOOQq
56ArwIwDKF7Tscd0oANRuYaNnPPJrM9D4drHITmK/V6zEerSs6UvJYJ4W+avaWnU
DIV+jdQEXJRvflKN/4UdCqF/jdVIXutgkyXbGA3gkwWV0SDbeQPpbPiP5NYO5TI0
Tt1MwY0dWXE9t6GmD4i+k+ZrmMN2is8N7l4TEmBgs6HD+My+HQw2lpoS8rT4eJ76
eOEO6RSxeEc43Hn3e1oOgLj5EI7EaPT8IOtQdLK8qSwbbwc9ZXDN0DLzmCPHSF6B
lu0mYE/P+MXQAdwO2bH/Qp3ho24V1KAeO8TCBQIDAQABAoIBAB6jiFYQ4ZeuQLtp
afElenPTl4C4Jk5ZRnlS51A4qaDL9XN2q05NUApB9KTK6nuxFaAOxs/OMqUt4t8C
3OvPkOdfa4ISRMwx9yq8N6QAGS7DAJOM6s2CsbWcezbLF5IRGD2joG5kBK6PweSS
CKcc+gehQgbdQ+yLrU34jLCPp4JikI3dFAfvn2LCR5IpKFMYgsLZtU5OFHth1HEr
yFmr+5wkZgP05x0dP0AiCx58XljhNivya3L1t6nf4ChztqIRMJDysskWGtkSbDW5
WTbnp3MNuXsCVycOCtdXhqC/pjz+nYicE3v/S1Fa0XPybk5tDdNZMvdL+4HAd8ab
0IJBJgkCgYEAypW9zypoeep/VEP5yYzQuHuw928duPW6rkGICj5vTJQlQkHjXVdA
YOFospBVsia+90QEXSLr992zFNp8NVq2dXg/7BxS5AHQDGpdKbDKE46Xf26FJyAX
DkEeQMZdNlTA3D1M8bY40c5awvqsBLI0e1X/yePgiF2v+ySuVxZSE/cCgYEAxSg8
iuphgLi03XvFxpdn01+jlIpH/Gd5SmUKg8wr720+YMEryASjoTGWe2GT91kyiFz4
rBt+aBbjOOpB5t4ujMApsc/puUGPyiwSuykFdnMw/VLsSrpTuM0m3tNeA6pTjTY9
hQ4zNc4vZUEtH5fVKXJKcxpBVLPmkofFt25L4uMCgYEAg2FVNXMlSluftABZkDJ4
cgwVmoI/XmJObRAmr64J9DnnZ+7fCvu4zpugkJ02VlD2a9l6kwRA0ADBUPbYsqlf
xxLzMaa0wxXB3Stlu9HhW4mQCp6cT+Fp0l68xflfHgsdADfpHKC2fKo9BlIXGPyR
OKNvPXlBdm574H3LasMY+8UCgYEArhefjlL0kgOHweOfeoMLbTyQZ4PLmPeNxMGA
DW1mhl8Cq9EnZdGi452z8XLyg4HB+2ONOfx1HFjJf+JrGv+qPyMYLikXizx3SeCt
EZNhfXyuD6L/f+UUNKUC49PkunvWl2UD4c/uLF7KvzBUNgeOdLC1SPowIilROqal
UhoU7F0CgYApqNZNoifMtlVplKuT6mtJXuz/8uUaSsIimsh76LID1y5Sx15YWcc9
bs4aiW3YGeW01GQNGJ/D5qL8Gw47Yy8wfcTlmWqUZI3OK19uH9EnHuMnLbY30r3a
mUZgQsPMcz9bI6jQWG2iygcMEvsl2XCdlxpnkHssdEjOxd79GfByhw==
-----END RSA PRIVATE KEY-----
openssl pkcs8 -topk8 -in rs256_private_key.pem -nocrypt -out rs256_pkcs8_private_key.pem
生成的PKCS8格式私钥示例
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCcBRJfGq/t2ytv
jYh3BHzIn6xiLRgJ25Ndtw066tUu72A45CrnoCvAjAMoXtOxx3SgA1G5ho2c88ms
z0Ph2schOYr9XrMR6tKzpS8lgnhb5q9padQMhX6N1ARclG9+Uo3/hR0KoX+N1Uhe
62CTJdsYDeCTBZXRINt5A+ls+I/k1g7lMjRO3UzBjR1ZcT23oaYPiL6T5muYw3aK
zw3uXhMSYGCzocP4zL4dDDaWmhLytPh4nvp44Q7pFLF4Rzjcefd7Wg6AuPkQjsRo
9Pwg61B0srypLBtvBz1lcM3QMvOYI8dIXoGW7SZgT8/4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/MFQ2B450sLVI+jAiKVE6pqVSGhTsXQKBgCmo1k2iJ8y2VWmUq5Pq
a0le7P/y5RpKwiKayHvosgPXLlLHXlhZxz1uzhqJbdgZ5bTUZA0Yn8PmovwbDjtj
LzB9xOWZapRkjc4rX24f0Sce4ycttjfSvdqZRmBCw8xzP1sjqNBYbaLKBwwS+yXZ
cJ2XGmeQeyx0SM7F3v0Z8HKH
-----END PRIVATE KEY-----
openssl rsa -in rs256_pkcs8_private_key.pem -out rs256_private_key.pem
生成的PKCS1格式私钥示例
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAnAUSXxqv7dsrb42IdwR8yJ+sYi0YCduTXbcNOurVLu9gOOQq
56ArwIwDKF7Tscd0oANRuYaNnPPJrM9D4drHITmK/V6zEerSs6UvJYJ4W+avaWnU
DIV+jdQEXJRvflKN/4UdCqF/jdVIXutgkyXbGA3gkwWV0SDbeQPpbPiP5NYO5TI0
Tt1MwY0dWXE9t6GmD4i+k+ZrmMN2is8N7l4TEmBgs6HD+My+HQw2lpoS8rT4eJ76
eOEO6RSxeEc43Hn3e1oOgLj5EI7EaPT8IOtQdLK8qSwbbwc9ZXDN0DLzmCPHSF6B
lu0mYE/P+MXQAdwO2bH/Qp3ho24V1KAeO8TCBQIDAQABAoIBAB6jiFYQ4ZeuQLtp
afElenPTl4C4Jk5ZRnlS51A4qaDL9XN2q05NUApB9KTK6nuxFaAOxs/OMqUt4t8C
3OvPkOdfa4ISRMwx9yq8N6QAGS7DAJOM6s2CsbWcezbLF5IRGD2joG5kBK6PweSS
CKcc+gehQgbdQ+yLrU34jLCPp4JikI3dFAfvn2LCR5IpKFMYgsLZtU5OFHth1HEr
yFmr+5wkZgP05x0dP0AiCx58XljhNivya3L1t6nf4ChztqIRMJDysskWGtkSbDW5
WTbnp3MNuXsCVycOCtdXhqC/pjz+nYicE3v/S1Fa0XPybk5tDdNZMvdL+4HAd8ab
0IJBJgkCgYEAypW9zypoeep/VEP5yYzQuHuw928duPW6rkGICj5vTJQlQkHjXVdA
YOFospBVsia+90QEXSLr992zFNp8NVq2dXg/7BxS5AHQDGpdKbDKE46Xf26FJyAX
DkEeQMZdNlTA3D1M8bY40c5awvqsBLI0e1X/yePgiF2v+ySuVxZSE/cCgYEAxSg8
iuphgLi03XvFxpdn01+jlIpH/Gd5SmUKg8wr720+YMEryASjoTGWe2GT91kyiFz4
rBt+aBbjOOpB5t4ujMApsc/puUGPyiwSuykFdnMw/VLsSrpTuM0m3tNeA6pTjTY9
hQ4zNc4vZUEtH5fVKXJKcxpBVLPmkofFt25L4uMCgYEAg2FVNXMlSluftABZkDJ4
cgwVmoI/XmJObRAmr64J9DnnZ+7fCvu4zpugkJ02VlD2a9l6kwRA0ADBUPbYsqlf
xxLzMaa0wxXB3Stlu9HhW4mQCp6cT+Fp0l68xflfHgsdADfpHKC2fKo9BlIXGPyR
OKNvPXlBdm574H3LasMY+8UCgYEArhefjlL0kgOHweOfeoMLbTyQZ4PLmPeNxMGA
DW1mhl8Cq9EnZdGi452z8XLyg4HB+2ONOfx1HFjJf+JrGv+qPyMYLikXizx3SeCt
EZNhfXyuD6L/f+UUNKUC49PkunvWl2UD4c/uLF7KvzBUNgeOdLC1SPowIilROqal
UhoU7F0CgYApqNZNoifMtlVplKuT6mtJXuz/8uUaSsIimsh76LID1y5Sx15YWcc9
bs4aiW3YGeW01GQNGJ/D5qL8Gw47Yy8wfcTlmWqUZI3OK19uH9EnHuMnLbY30r3a
mUZgQsPMcz9bI6jQWG2iygcMEvsl2XCdlxpnkHssdEjOxd79GfByhw==
-----END RSA PRIVATE KEY-----
openssl rsa -pubout -in rs256_private_key.pem -out rs256_public_key.pem
或
openssl rsa -pubout -in rs256_pkcs8_private_key.pem -out rs256_public_key.pem
生成的公钥示例
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnAUSXxqv7dsrb42IdwR8
yJ+sYi0YCduTXbcNOurVLu9gOOQq56ArwIwDKF7Tscd0oANRuYaNnPPJrM9D4drH
ITmK/V6zEerSs6UvJYJ4W+avaWnUDIV+jdQEXJRvflKN/4UdCqF/jdVIXutgkyXb
GA3gkwWV0SDbeQPpbPiP5NYO5TI0Tt1MwY0dWXE9t6GmD4i+k+ZrmMN2is8N7l4T
EmBgs6HD+My+HQw2lpoS8rT4eJ76eOEO6RSxeEc43Hn3e1oOgLj5EI7EaPT8IOtQ
dLK8qSwbbwc9ZXDN0DLzmCPHSF6Blu0mYE/P+MXQAdwO2bH/Qp3ho24V1KAeO8TC
BQIDAQAB
-----END PUBLIC KEY-----