注册开放平台账号

支付宝开放平台: https://open.alipay.com/


生成密钥

下载 RSA密钥工具

一键生成RSA密钥工具”下载地址: https://docs.open.alipay.com/291/106097/


生成秘钥

切换到生成秘钥 tab,秘钥格式选择“PKCS1(非JAVA适用)


新建 private-key.pem 保存私钥

完整的 private-key.pem 文件例子:

MIIEpQIBAAKCAQEA7EqgH28GDbCgaonIDWIhMSPYAGMLNjCzmk7jtxNSLFjI+bbTZe43N5Bbo8cmk/LpULIGrtiyhfre1WMWIG6voK/GNL+9pY3PxkOdr+VveWp3ZDuaWQToN7Tq/f+MUMkvEBhcCP+b7UheQXX80zAEWe7HGh5mpj9bmbtb57d34e1b72GX/dTVVeJDU5/Eg6L/UcKeOmd4xtdGP4xqAPbgNhe2JuTOtRR/xl0ZT9mUtEpBLabrTR1EO256Zk1lzgXuMepAlyCIN0Rm0DxqnosRZjRg41ahkXs3RzInRbWXIIVdrjJsjC7rnlt6zZHdqRSDKy/9sZbAv0e8ZjaHjIEnvQIDAQABAoIBAHF2zDkL6Q492GoQS14R1vpvydM1vDaDYFsisrpArt7Yq3ktz4lMwHsP+NFGWkIFDQBQ3GCtcdxgQQyajg941yEEBtthj0GmPTVpVpkWRVc6RqZ88Hr6nj/Rwl3BjrFkShMif19azpc8fvZUH9mRXyWIQVdLbeM63VOO4mz8bravhYxX3Mea8sTzo4mzfM2J+E9eLsywrFNQ44HueQZrK6d1fFdEe1bC9BrDd9xWVPuOgKBZiAnpcSla9CHbmD4YFBOmGV1/+gnoDBJuaHNij4K9AuJSz90dnRUuByVfR9vMxENkBOIoOpIjs8+WvF+L2e1qKe4WhX89p9i+rpIb28kCgYEA+q0bo7s0YugkXPCMGyK0hH/CoUqkx/sPjM1lJoXc24NtorX1MZcqH0Pa55A+6rfYAiRYcW7fv+nqmc8Bz32dTWROdL27wloHBkO+p7ZuSnc6b6L1rk5da77gC4DmI01LSFXT36dRFWJOBj7rWCp0pUlxmexp+VLrEEhzJs4Ob48CgYEA8U9PVR3gUV60mymSel4o0sMcALANt5SZvX2GoJ3FMFPWLyAq7WFZnttPjwXaqEda5efB9Brp0Wm092kTcMAcus3Rkytt/DSGVGAWhkF9FcPG06mpL2UK3z6glvdOq2zjCo6oglVtCOUKj0sxXYjXAhqF/SPw3Kgov2Ru9hMtDfMCgYEA0UlN1jkp15nxIhdDIjSreiQgnwDu6nfV17x0QuFoL21fT4WTHMAUTt4cGVD49oZfNgqaPLpQ3K2zTI7j+BPsDP0984GlDPKVAsn0l5lcI5e/lgz8CXcr0BUggPoxKjASNmZR6lyK+cuFUPmfC5EGqijTS6tyHtL3pjSWz0MiEkkCgYEAhSR9YTlay4q1m+cUKvBJFgERMk/xQZl8OlFINtbWNhQL2XSmOtO73yqiewd/3dmBDdkR6t3upNzuPJR9ZXiaYXeuasVLqhxRAb0CsJDxs1CSI7c44i2eEg88DA/oGC28F9ceosr/nijB6s5SLomSGFcKFuH9w8IEuZVwo9VwxoECgYEA4BM+BBRhtOQd8ae/Y8vAH828X9euupkhIrpQvk3iptNowAniiCoDXmQtwQOyDj8O9NkvCKRZcH5eApLrDo7dIQg5bvcT894MotSDbcEBvLkLvcKfb/Vw0GFVUhUAGRebyATkA7mDCeJ1VMyj/d6Ubg5FOy7L/U4X+Qwrwb/B/VA=


设置应用公钥

复制 2.2 中生成的应用公钥



登录开放平台设置应用公钥



保存支付宝公钥

“支付宝公钥”用于开放平台返回值的进行验签


开放平台“应用概览”页面中复制“支付宝公钥”



新建 public-key.pem 保存私钥

完整的 public-key.pem 文件例子:

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7EqgH28GDbCgaonIDWIhMSPYAGMLNjCzmk7jtxNSLFjI+bbTZe43N5Bbo8cmk/LpULIGrtiyhfre1WMWIG6voK/GNL+9pY3PxkOdr+VveWp3ZDuaWQToN7Tq/f+MUMkvEBhcCP+b7UheQXX80zAEWe7HGh5mpj9bmbtb57d34e1b72GX/dTVVeJDU5/Eg6L/UcKeOmd4xtdGP4xqAPbgNhe2JuTOtRR/xl0ZT9mUtEpBLabrTR1EO256Zk1lzgXuMepAlyCIN0Rm0DxqnosRZjRg41ahkXs3RzInRbWXIIVdrjJsjC7rnlt6zZHdqRSDKy/9sZbAv0e8ZjaHjIEnvQIDAQAB