Generate RSA key: https://cshall.alipay.com/enterprise/help_detail.htm?help_id=474010
The first command generates the original private key (used by PHP)
genrsa -out rsa_private_key.pem 1024
The second command is the private key in pkcs8 format (for languages other than php, it needs to be copied and saved separately)
pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt
The third command generates the public key (Upload to the Add Key under Partner Key Management)
rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
Signature Mechanism
Uploading the public key is to encrypt our Alipay with your private key when you request it You use your public key to verify the signature
On the contrary, after the asynchronous notification returns and the Alipay signature returns, you use our Alipay public key to verify the signature
PID and public key management:
The open platform is a wireless payment method The product web is an old version of the mobile website and the other payments are under the management of partners
Mobile terminal configuration
The public key is the Alipay public key (each merchant has the same unified public key), the public key generated by yourself The key is uploaded to the partner secret key management. The private key is the private key in pkcs8 format. The server configuration is the public key. (Every merchant has the same unified public key.) The private key is Private key generated by openssl, standard private key file example (for PHP, .NET), PKCS8 processed private key file example (for Java)
The above introduces the generation of RSA private key and public key when integrating Alipay, including Alipay and RSA content. I hope it will be helpful to friends who are interested in PHP tutorials.