Detailed process of RSA encrypted public/private key file generation in iOS
1. Use openssl to generate the required key file
The generation environment is generated under the mac system using openssl. First, open the terminal and follow these steps in sequence:
1. Generate a private key file private_key.pem with a modulus of 1024 bits
openssl genrsa -out private_key.pem 1024
2. Generate the certificate request file rsaCertReq.csr (this step will prompt to enter the country, province, mail and other information, you can fill in according to the actual situation, or you don't need to fill in all, just hit enter.)
openssl req -new -key private_key.pem -out rsaCerReq.csr
3. Generate the certificate rsaCert.crt and set the valid time
openssl x509 -req -days 3650 -in rsaCerReq.csr -signkey private_key.pem -out rsaCert.crt
4. Generate the public key file public_key.der for iOS use
openssl x509 -outform der -in rsaCert.crt -out public_key.der
5. Generate the private key file private_key.p12 for iOS
openssl pkcs12 -export -out private_key.p12 -inkey private_key.pem -in rsaCert.crt
2. Import the file into the project for use
Import the public key file public_key.der and private key file private_key.p12 of the bio layer into the project
By default, the generated file is in the /user/userName/ path