Generate an RSA key pair
RSA key pair
An RSA key pair contains the private key and the public key. The private key is required for generating the signature, while the public key is used for verifying the signature.
Generating an RSA key pair
Many tools can be used to generate the RSA key pair. The following steps assume that you use OpenSSL to generate the RSA key pair.
- Install OpenSSL.
For Linux system, use the following command:
copy
sudo apt-get install openssl
For windows system, download and then install OpenSSL from the official site
- Generate RSA2 key pair.
For Linux system, use the following command:
copy
$ openssl
OpenSSL> genrsa -out rsa_private_key.pem 2048 ##generate private key
OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM - nocrypt ##transform private key into PKCS8 format
OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
##Generate public key
OpenSSL> exit
Uploading RSA public key
After the RSA2 key pair is generated, you must exchange the public key with the AlipayHK server for signature verification by completing the following steps:
- Upload your public key to AlipayHK
- Obatin AlipayHK public key