密钥生成
RSA公私钥生成
生成方式:使用 OpenSSL 命令生成。
#生成1024位私钥
OpenSSL> genrsa -out rsa_private_key.pem 1024
#开发者需要将私钥转换成PKCS8格式
OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out rsa_private_key_pkcs8.pem
#生成公钥
OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
OpenSSL> exit
在当前文件夹执行上述命令后,会生成 rsa_private_key.pem ( RSA 私钥)、 rsa_private_key_pkcs8.pem ( pkcs8 格式 RSA 私钥)和 rsa_public_key.pem (对应 RSA 公钥) 3 个文件。开发者需要将私钥文件保留,将公钥内容提交给百度,此公钥是百度系统识别开发者的唯一有效凭证。
标准公私钥文件内容示例
1024位标准私钥文件
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQC6ZbnSK6EeCMFq3KUdp2hyd5ExvfPYy65berLkjm8eKX2swDq9
nF+bpCtM27+0pssRuoypaBIOTP3nf+Qpd1p8yP8kMQF3GbUy1t9kZzs0lqpGe7RZ
/7ehVKIyLlCEgm5cUMFGKyLH33XL1QcQkqAJjinbjgYjtvt1Ms+VCmmolwIDAQAB
AoGBAJ9H/HGHzOeAbd/masabXtqqKA3Ml4rECturTyGWQYgRxo4PumJ7NQwoTsQf
6IL0IQWmVzsQbpV/31yq4gs5Lb2MzXDAsfAWkj+Z4xCvApLyzCgrS9HomKl/PM4W
tZeCH7rYiqs2eTtqGlV/zBwKe5sUQJ7uTkSqePkGz9+WyVw5AkEA49tYgWlv2vkf
WPNq5Rv4ouPRBbNFCGJiWD5jBl2cGEhywfsEfZsqGzUPkgFI+rs4VPWyHzwUuVRU
bJhcfyBPJQJBANFrdvaFkiNdjpay+VRlMRgPkOB4wlXk+16RgX5tj5WJY/yKOEGI
k6T8tExXJuwzp2b/zqdqjGJYDawbBiOimgsCQEZyPGzWUlTbDMwNhhELktWZpbgj
csZi1JD/yNHhAy+mxoQevYawAFalEwlLCGsskwABbm6l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