密钥生成

RSA公私钥生成

生成方式:使用 OpenSSL 命令生成。

  1. #生成1024位私钥
  2. OpenSSL> genrsa -out rsa_private_key.pem 1024
  3. #开发者需要将私钥转换成PKCS8格式
  4. OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out rsa_private_key_pkcs8.pem
  5. #生成公钥
  6. OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
  7. OpenSSL> exit

在当前文件夹执行上述命令后,会生成 rsa_private_key.pem ( RSA 私钥)、 rsa_private_key_pkcs8.pem ( pkcs8 格式 RSA 私钥)和 rsa_public_key.pem (对应 RSA 公钥) 3 个文件。开发者需要将私钥文件保留,将公钥内容提交给百度,此公钥是百度系统识别开发者的唯一有效凭证。

标准公私钥文件内容示例

1024位标准私钥文件

  1. -----BEGIN RSA PRIVATE KEY-----
  2. MIICXQIBAAKBgQC6ZbnSK6EeCMFq3KUdp2hyd5ExvfPYy65berLkjm8eKX2swDq9
  3. nF+bpCtM27+0pssRuoypaBIOTP3nf+Qpd1p8yP8kMQF3GbUy1t9kZzs0lqpGe7RZ
  4. /7ehVKIyLlCEgm5cUMFGKyLH33XL1QcQkqAJjinbjgYjtvt1Ms+VCmmolwIDAQAB
  5. AoGBAJ9H/HGHzOeAbd/masabXtqqKA3Ml4rECturTyGWQYgRxo4PumJ7NQwoTsQf
  6. 6IL0IQWmVzsQbpV/31yq4gs5Lb2MzXDAsfAWkj+Z4xCvApLyzCgrS9HomKl/PM4W
  7. tZeCH7rYiqs2eTtqGlV/zBwKe5sUQJ7uTkSqePkGz9+WyVw5AkEA49tYgWlv2vkf
  8. WPNq5Rv4ouPRBbNFCGJiWD5jBl2cGEhywfsEfZsqGzUPkgFI+rs4VPWyHzwUuVRU
  9. bJhcfyBPJQJBANFrdvaFkiNdjpay+VRlMRgPkOB4wlXk+16RgX5tj5WJY/yKOEGI
  10. k6T8tExXJuwzp2b/zqdqjGJYDawbBiOimgsCQEZyPGzWUlTbDMwNhhELktWZpbgj
  11. csZi1JD/yNHhAy+mxoQevYawAFalEwlLCGsskwABbm6lvqqF3gwtFvve21kCQFQ3
  12. RjDfCCTGs9ewg4nH49VMNTO//E60dc3S7+NaxdoZ1SayourftJgts4fbqGBmaVSH
  13. XKCAvZGy3VSvzWk5M38CQQCozKD1ddDDrtE2gQKtKAjOzcvgJsell085f1cObc/C
  14. pRG0IMfXcGi352IS5xbgJWnX+9UZwW5UppDJr6YKFA1K
  15. -----END RSA PRIVATE KEY-----

PKCS8处理后的私钥文件

  1. -----BEGIN PRIVATE KEY-----
  2. MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALpludIroR4IwWrc
  3. pR2naHJ3kTG989jLrlt6suSObx4pfazAOr2cX5ukK0zbv7SmyxG6jKloEg5M/ed/
  4. 5Cl3WnzI/yQxAXcZtTLW32RnOzSWqkZ7tFn/t6FUojIuUISCblxQwUYrIsffdcvV
  5. BxCSoAmOKduOBiO2+3Uyz5UKaaiXAgMBAAECgYEAn0f8cYfM54Bt3+Zqxpte2qoo
  6. DcyXisQK26tPIZZBiBHGjg+6Yns1DChOxB/ogvQhBaZXOxBulX/fXKriCzktvYzN
  7. cMCx8BaSP5njEK8CkvLMKCtL0eiYqX88zha1l4IfutiKqzZ5O2oaVX/MHAp7mxRA
  8. nu5ORKp4+QbP35bJXDkCQQDj21iBaW/a+R9Y82rlG/ii49EFs0UIYmJYPmMGXZwY
  9. SHLB+wR9myobNQ+SAUj6uzhU9bIfPBS5VFRsmFx/IE8lAkEA0Wt29oWSI12OlrL5
  10. VGUxGA+Q4HjCVeT7XpGBfm2PlYlj/Io4QYiTpPy0TFcm7DOnZv/Op2qMYlgNrBsG
  11. I6KaCwJARnI8bNZSVNsMzA2GEQuS1ZmluCNyxmLUkP/I0eEDL6bGhB69hrAAVqUT
  12. CUsIayyTAAFubqW+qoXeDC0W+97bWQJAVDdGMN8IJMaz17CDicfj1Uw1M7/8TrR1
  13. zdLv41rF2hnVJrKi6t+0mC2zh9uoYGZpVIdcoIC9kbLdVK/NaTkzfwJBAKjMoPV1
  14. 0MOu0TaBAq0oCM7Ny+Amx6WXTzl/Vw5tz8KlEbQgx9dwaLfnYhLnFuAladf71RnB
  15. blSmkMmvpgoUDUo=
  16. -----END PRIVATE KEY-----

标准公钥文件

  1. -----BEGIN PUBLIC KEY-----
  2. MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6ZbnSK6EeCMFq3KUdp2hyd5Ex
  3. vfPYy65berLkjm8eKX2swDq9nF+bpCtM27+0pssRuoypaBIOTP3nf+Qpd1p8yP8k
  4. MQF3GbUy1t9kZzs0lqpGe7RZ/7ehVKIyLlCEgm5cUMFGKyLH33XL1QcQkqAJjinb
  5. jgYjtvt1Ms+VCmmolwIDAQAB
  6. -----END PUBLIC KEY-----