Generating 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.

1.Install OpenSSL.

For linux system, use the following command:

sudo apt-get install openssl

For windows system, download and then install OpenSSL from the official site

2.Generate RSA2 key pair.

For linux system, use the following command:

$ 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:

  1. Upload your public key to AlipayHK
  2. Obatin AlipayHK public key